[New-bugs-announce] [issue41519] `pkgutil.get_data` causes future imports of children modules to fail.

Cory Nezin report at bugs.python.org
Mon Aug 10 16:37:28 EDT 2020


New submission from Cory Nezin <cory.nezin at gmail.com>:

As demonstrated in this Stack Overflow question (https://stackoverflow.com/questions/59377661/python-pkgutil-get-data-disrupts-future-imports) using `pkgutil.get_data` on a module causes future imports of children modules to fail.  I tracked this down to a call to `importlib._bootstrap.load` here: https://github.com/python/cpython/blob/3.8/Lib/pkgutil.py#L627

This seems to do something to sys.modules which I don't quite understand but I think it is caching the module when it shouldn't be.  If I replace the linked line with `importlib.import_module(package))` it seems to work okay.

----------
components: Library (Lib)
files: pkgutil_err.tar
messages: 375149
nosy: cnezin
priority: normal
severity: normal
status: open
title: `pkgutil.get_data` causes future imports of children modules to fail.
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49381/pkgutil_err.tar

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41519>
_______________________________________


More information about the New-bugs-announce mailing list