Skip to content

Commit 383a668

Browse files
authored
Preserve __package__ attribute from original module
https://www.python.org/dev/peps/pep-0302/#specification-part-1-the-importer-protocol: "The __package__ attribute [8] must be set."
1 parent 9c7a93c commit 383a668

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/apipkg/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def initpkg(pkgname, exportdefs, attr=None, eager=False):
5151
d['__loader__'] = oldmod.__loader__
5252
if hasattr(oldmod, '__path__'):
5353
d['__path__'] = [_py_abspath(p) for p in oldmod.__path__]
54+
if hasattr(oldmod, '__package__'):
55+
d['__package__'] = oldmod.__package__
5456
if '__doc__' not in exportdefs and getattr(oldmod, '__doc__', None):
5557
d['__doc__'] = oldmod.__doc__
5658
d.update(attr)

0 commit comments

Comments
 (0)