Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.

…ckage

instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.
@mention-bot
Copy link

@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @pitrou and @ericsnowcurrently to be potential reviewers.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual changes look good to me, but I believe the NEWS snippet can go in Misc/NEWS.d now

Misc/NEWS Outdated
Core and Builtins
-----------------

- bpo-30876: Relative import from unloaded package now reimports the package
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a file in NEWS.d now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wait until blurb 1.0.1 become available on PyPI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka It seems to be available on PyPi, I just download via pip.

Collecting blurb
  Downloading blurb-1.0.1-py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 547kB/s 
Installing collected packages: blurb
Successfully installed blurb-1.0.1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly command do you use? I used python3 -m pip install --user blurb and it installed blurb-1.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you already have a version of blurb installed, you may need --upgrade to get it to upgrade to the latest one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first uninstalled blurb. If install blurb, the --upgrade option doesn't have any effect.

$ python3 -m pip install --user --upgrade blurb
Requirement already up-to-date: blurb in /home/serhiy/.local/lib/python3.5/site-packages

Copy link
Contributor

@mlouielu mlouielu Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is because core-workflow add the pre-requirement on PyPI in 1.0.1 version: Requires Python: >=3.6. You can saw it at 1.0.1, since the latest version which didn't require Python 3.6 is 1.0, you will only get 1.0 on Python 3.5 :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I installed blurb from source:

  • clone /home/haypo/prog/python/core-workflow
  • enter blurb/ directory
  • install flit: sudo python3 -m pip install -U flit
  • install blurb using flit: sudo python3 -m flit install

(I would also prefer to get it using pip ;-))

@serhiy-storchaka
Copy link
Member Author

Blurb 1.0.1 works with 3.5, but requires 3.6, and blurb 1.0 requires 3.5, but works only with 3.6?

@brettcannon
Copy link
Member

@serhiy-storchaka it's all a mistake because no one updated the blurb.ini file for blurb in the PRs to add Python 3.5 support. I've now fixed it and will do an updated release sometime this week (I'll try to do it today).

And just for reference this was reported in python/core-workflow#159.

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking for some changes to use utility code to make test cleanup easier. Otherwise the solution is surprisingly simple. 😄

try:
import package2.submodule1
package2.submodule1.submodule2
finally:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this cleanup can be handled by the test.test_importlib.util.import_state and uncache context managers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Brett. I afraid that test.test_importlib.util.import_state does too much, I think test.support.DirsOnSysPath should be enough.

I wondering what is better, provide test files as a part of the source tree, or create them from zero in a temporary directory?

import submodule1
self.assertNotIn('submodule1', sys.modules)
self.assertNotIn('submodule2', sys.modules)
finally:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use test.test_importlib.util.import_state to manage sys.path mutations.

@serhiy-storchaka serhiy-storchaka merged commit 8a9cd20 into python:master Jul 12, 2017
@serhiy-storchaka serhiy-storchaka deleted the import-from-unknown-package branch July 12, 2017 03:50
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 12, 2017
…the package (pythonGH-2639)

instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError..
(cherry picked from commit 8a9cd20)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 12, 2017
…the package (pythonGH-2639)

instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError..
(cherry picked from commit 8a9cd20)
serhiy-storchaka added a commit that referenced this pull request Jul 16, 2017
…the package (GH-2639) (#2676)

instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.
(cherry picked from commit 8a9cd20)
serhiy-storchaka added a commit that referenced this pull request Jul 23, 2017
* bpo-30876: Relative import from unloaded package now reimports the package
instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.
(cherry picked from commit 8a9cd20)

* bpo-18018: Import raises ImportError instead of SystemError if a relative
import is attempted without a known parent package.

* bpo-26367: importlib.__init__() raises ImportError like
builtins.__import__() when ``level`` is specified but without an accompanying
package specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants