Issue 19409: pkgutil isn't importable from a file or the REPL (original) (raw)

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: Alyssa 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 import pkgutil File "/home/ncoghlan/devel/py3k/Lib/pkgutil.py", line 161, in importlib.machinery.FileFinder, _iter_file_finder_modules) AttributeError: 'module' object has no attribute 'machinery'
msg201359 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013-10-26 14:21
Also "make clobber" and a rebuild didn't fix it.
msg201360 - (view) Author: Alyssa 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: Alyssa 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: Alyssa 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:52 admin set github: 63608
2013-10-26 14:35:20 ncoghlan set messages: +
2013-10-26 14:33:42 ncoghlan set messages: +
2013-10-26 14:28:14 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2013-10-26 14:26:12 ncoghlan set assignee: ncoghlan
2013-10-26 14:25:13 ncoghlan set messages: +
2013-10-26 14:21:45 ncoghlan set messages: +
2013-10-26 14:06:48 ncoghlan set nosy: + ncoghlan, brett.cannonmessages: +
2013-10-26 13:57:29 dstufft create