mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-30645: don't append to an inner loop path in imp.load_package() (GH-2268)
Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``. Patch by Alexandru Ardelean.
This commit is contained in:
parent
d174d24a5d
commit
c38e32a100
3 changed files with 8 additions and 2 deletions
|
@ -203,8 +203,9 @@ def load_package(name, path):
|
|||
extensions = (machinery.SOURCE_SUFFIXES[:] +
|
||||
machinery.BYTECODE_SUFFIXES[:])
|
||||
for extension in extensions:
|
||||
path = os.path.join(path, '__init__'+extension)
|
||||
if os.path.exists(path):
|
||||
init_path = os.path.join(path, '__init__' + extension)
|
||||
if os.path.exists(init_path):
|
||||
path = init_path
|
||||
break
|
||||
else:
|
||||
raise ValueError('{!r} is not a package'.format(path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue