mirror of
https://github.com/openwrt/packages.git
synced 2025-12-19 17:11:21 +00:00
python3: fix distutils path to package when using bytecodes
If there is only Python bytecodes, then the __init__.py script will be concatenated, and the __init__.pyc as well. This is becase this bit `path = os.path.join(path, '__init__'+extension)` is iterated twice. This is a bug in Python3, also because we ship bytecodes instead of source code [ with Python & Python3 ]. Python is not affected. Reported-by: Mirko Vogt <mirko@nanl.de> Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
diff --git a/Lib/imp.py b/Lib/imp.py
|
||||
index 781ff23..beeac70 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))
|
||||
Reference in New Issue
Block a user