This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pkgutil isn't importable from a file or the REPL
Type: behavior Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: brett.cannon, dstufft, larry, ncoghlan, python-dev
Priority: release blocker Keywords:

Created on 2013-10-26 13:57 by dstufft, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg201355 - (view) Author: Donald Stufft (dstufft) * (Python committer) Date: 2013-10-26 13:57
Currently pkgutil cannot be imported unless you first import importlib.machinery. This means ./python.exe -m pkgutil works, but doing ``import pkgutil`` in the REPL does not.
msg201356 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:06
I'm seeing the same symptom locally.

If you use -m to execute things, the problem isn't noticeable because runpy imports importlib.machinery. It looks like test.regrtest imports it as well:

$ ./python -m test test_pkgutil
[1/1] test_pkgutil
1 test OK.
$ ./python Lib/test/regrtest.py test_pkgutil
[1/1] test_pkgutil
1 test OK.
$ ./python Lib/test/test_pkgutil.py
Traceback (most recent call last):
  File "Lib/test/test_pkgutil.py", line 5, in <module>
    import pkgutil
  File "/home/ncoghlan/devel/py3k/Lib/pkgutil.py", line 161, in <module>
    importlib.machinery.FileFinder, _iter_file_finder_modules)
AttributeError: 'module' object has no attribute 'machinery'
msg201359 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:21
Also "make clobber" and a rebuild didn't fix it.
msg201360 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:25
Turns out the relevant import is just plain missing from pkgutil, and we didn't notice because so many other things import it :P
msg201361 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-26 14:28
New changeset 0c0cbba64b7b by Nick Coghlan in branch 'default':
Close #19409: add missing import in pkgutil
http://hg.python.org/cpython/rev/0c0cbba64b7b
msg201362 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:33
Ah, I figured out which commit broke it, too: the one that deprecated the imp module (see http://hg.python.org/cpython/rev/1b8f08c4efd5)

Previously, the importlib.machinery dependency was satisfied indirectly through imp.
msg201363 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:35
I checked the other modules that previously imported imp, and they're all fine.
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63608
2013-10-26 14:35:20ncoghlansetmessages: + msg201363
2013-10-26 14:33:42ncoghlansetmessages: + msg201362
2013-10-26 14:28:14python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg201361

resolution: fixed
stage: resolved
2013-10-26 14:26:12ncoghlansetassignee: ncoghlan
2013-10-26 14:25:13ncoghlansetmessages: + msg201360
2013-10-26 14:21:45ncoghlansetmessages: + msg201359
2013-10-26 14:06:48ncoghlansetnosy: + ncoghlan, brett.cannon
messages: + msg201356
2013-10-26 13:57:29dstufftcreate