aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2018-07-08 18:40:33 +0200
committerChristian Tismer <tismer@stackless.com>2018-07-09 15:34:00 +0000
commit55d89709967354e606313a6078f580c8073a6dd8 (patch)
treec0c9419093bea05230590739031235b14f62126a
parent5662706937bd6a1449538539e3a503c6cbc45399 (diff)
Fix Limited API and Signature Glitches in Python 3.7
When the homebrew version of Python 3.7 appeared so unforeseen early, I felt inclined to fix these glitches, immediately: In Python 3.7, the typing module was more changed than expected. Since we don't support versions below 3.5, it was easy to fix by avoiding to copy typing.py for version 3.x, altogether. It stays there for Python 2.7 . Furthermore, the Python issue 33738 will later be solved than the code expected, so I fixed that one for all by a macro definition. Task-number: PYSIDE-741 Change-Id: Ia56ccd1ef20cb9536b1d39f190e011e5dccf1f22 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/pyside2/PySide2/CMakeLists.txt4
-rw-r--r--sources/pyside2/PySide2/support/signature/loader.py2
-rw-r--r--sources/pyside2/PySide2/support/signature/mapping.py5
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp2
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.h7
5 files changed, 9 insertions, 11 deletions
diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt
index c109b2e0e..0263f7441 100644
--- a/sources/pyside2/PySide2/CMakeLists.txt
+++ b/sources/pyside2/PySide2/CMakeLists.txt
@@ -47,10 +47,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/mapping.py"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/parser.py"
"${CMAKE_CURRENT_BINARY_DIR}/support/signature/parser.py" COPYONLY)
if (PYTHON_VERSION_MAJOR EQUAL 3)
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/inspect.py"
- "${CMAKE_CURRENT_BINARY_DIR}/support/signature/inspect.py" COPYONLY)
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/typing36.py"
- "${CMAKE_CURRENT_BINARY_DIR}/support/signature/typing.py" COPYONLY)
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/backport_inspect.py"
"${CMAKE_CURRENT_BINARY_DIR}/support/signature/backport_inspect.py" COPYONLY)
diff --git a/sources/pyside2/PySide2/support/signature/loader.py b/sources/pyside2/PySide2/support/signature/loader.py
index a5f38a6f4..1827ca454 100644
--- a/sources/pyside2/PySide2/support/signature/loader.py
+++ b/sources/pyside2/PySide2/support/signature/loader.py
@@ -59,7 +59,7 @@ for _ in "four":
package_dir = os.path.dirname(package_dir)
sys.path.insert(0, package_dir)
if sys.version_info >= (3,):
- from PySide2.support.signature import inspect
+ import inspect
else:
import inspect
namespace = inspect.__dict__
diff --git a/sources/pyside2/PySide2/support/signature/mapping.py b/sources/pyside2/PySide2/support/signature/mapping.py
index 3e05dbcb2..7151af8bb 100644
--- a/sources/pyside2/PySide2/support/signature/mapping.py
+++ b/sources/pyside2/PySide2/support/signature/mapping.py
@@ -55,8 +55,11 @@ See _resolve_value() in singature.py
import sys
import struct
import PySide2
+try:
+ from . import typing
+except ImportError:
+ import typing
-from . import typing
ellipsis = "..."
Char = typing.Union[str, int] # how do I model the limitation to 1 char?
StringList = typing.List[str]
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
index dcd844ed6..f0e8f3457 100644
--- a/sources/shiboken2/libshiboken/pep384impl.cpp
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp
@@ -449,7 +449,7 @@ check_PepTypeObject_valid(void)
#ifdef Py_LIMITED_API
-#if PY_VERSION_HEX < 0x03070000
+#if PY_VERSION_HEX < PY_ISSUE33738_SOLVED
#include "pep384_issue33738.cpp"
#endif
diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h
index bfc603f69..d5b0c7654 100644
--- a/sources/shiboken2/libshiboken/pep384impl.h
+++ b/sources/shiboken2/libshiboken/pep384impl.h
@@ -134,10 +134,9 @@ typedef struct _peptypeobject {
} PepTypeObject;
// This was a macro error in the limited API from the beginning.
-// It was fixed in Python 3.7 .
-// XXX The commit did go to master, but did not make it to 3.7, yet.
-//#if PY_VERSION_HEX < 0x03070000
-#if PY_VERSION_HEX < 0x03080000
+// It was fixed in Python master, but did make it only in Python 3.8 .
+#define PY_ISSUE33738_SOLVED 0x03080000
+#if PY_VERSION_HEX < PY_ISSUE33738_SOLVED
#undef PyIndex_Check
LIBSHIBOKEN_API int PyIndex_Check(PyObject *obj);
#endif