python3: fix distutils path to package when using bytecodes 4475/head
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Mon, 12 Jun 2017 20:17:05 +0000 (23:17 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Mon, 12 Jun 2017 20:26:54 +0000 (23:26 +0300)
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>
lang/python/python3/Makefile
lang/python/python3/patches/008-fix-distutils-path-creation.patch [new file with mode: 0644]

index 97c0f6efe634bf69c47df67e63f88203b84de3f8..5438a3ca7f6f7a7f5deea77fba6cf6e5338a5549 100644 (file)
@@ -14,7 +14,7 @@ PYTHON_VERSION:=$(PYTHON3_VERSION)
 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
 
 PKG_NAME:=python3
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
diff --git a/lang/python/python3/patches/008-fix-distutils-path-creation.patch b/lang/python/python3/patches/008-fix-distutils-path-creation.patch
new file mode 100644 (file)
index 0000000..8db6bdc
--- /dev/null
@@ -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))