diff --git a/Lib/imp.py b/Lib/imp.py index 781ff23d252161..866464b245b24c 100644 --- a/Lib/imp.py +++ b/Lib/imp.py @@ -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)) diff --git a/Misc/ACKS b/Misc/ACKS index 03f9ea6cc97ae3..c68f9eb9f18867 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -56,6 +56,7 @@ Ankur Ankan Heidi Annexstad Ramchandra Apte Éric Araujo +Alexandru Ardelean Alicia Arlen Jeffrey Armstrong Jason Asbahr diff --git a/Misc/NEWS b/Misc/NEWS index 94a29d0363c6ad..371dcf8ff0d0ac 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -101,6 +101,10 @@ Library variable-argument parameters wrapped with partialmethod. Patch by Dong-hee Na. +- bpo-30645: Fix path calculation in imp.load_package(), fixing it for + cases when a package is only shipped with bytecodes. Patch by + Alexandru Ardelean. + - bpo-29931: Fixed comparison check for ipaddress.ip_interface objects. Patch by Sanjay Sundaresan.