aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-13 07:57:00 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-13 07:57:07 +0200
commit7720b734ec0a6fc7db67509c248fc96346d930df (patch)
treea35cc706c02f5d0a4316156a60a4ab670089dcf9 /sources/shiboken2
parentab9172028363e0e9f12a7b2ef35b14ed00698dd4 (diff)
parenteb19b7190b1038bdb511ec3ffb6f0a217b58d3b8 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp73
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp4
-rw-r--r--sources/shiboken2/libshiboken/bufferprocs27.h25
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp2
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.h84
-rw-r--r--sources/shiboken2/libshiboken/qt_attribution.json4
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.cpp4
7 files changed, 93 insertions, 103 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
index 820909713..74cad05ae 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
@@ -95,6 +95,36 @@ static bool runProcess(const QString &program, const QStringList &arguments,
static QByteArray frameworkPath() { return QByteArrayLiteral(" (framework directory)"); }
+#if defined(Q_OS_MACOS)
+static void filterHomebrewHeaderPaths(HeaderPaths &headerPaths)
+{
+ QByteArray homebrewPrefix = qgetenv("HOMEBREW_OPT");
+
+ // If HOMEBREW_OPT is found we assume that the build is happening
+ // inside a brew environment, which means we need to filter out
+ // the -isystem flags added by the brew clang shim. This is needed
+ // because brew passes the Qt include paths as system include paths
+ // and because our parser ignores system headers, Qt classes won't
+ // be found and thus compilation errors will occur.
+ if (homebrewPrefix.isEmpty())
+ return;
+
+ qCInfo(lcShiboken) << "Found HOMEBREW_OPT with value:" << homebrewPrefix
+ << "Assuming homebrew build environment.";
+
+ HeaderPaths::iterator it = headerPaths.begin();
+ while (it != headerPaths.end()) {
+ if (it->path.startsWith(homebrewPrefix)) {
+ qCInfo(lcShiboken) << "Filtering out homebrew include path: "
+ << it->path;
+ it = headerPaths.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+#endif
+
// Determine g++'s internal include paths from the output of
// g++ -E -x c++ - -v </dev/null
// Output looks like:
@@ -130,6 +160,10 @@ static HeaderPaths gppInternalIncludePaths(const QString &compiler)
isIncludeDir = true;
}
}
+
+#if defined(Q_OS_MACOS)
+ filterHomebrewHeaderPaths(result);
+#endif
return result;
}
#endif // Q_CC_MSVC
@@ -148,12 +182,36 @@ static void detectVulkan(HeaderPaths *headerPaths)
}
#if defined(Q_CC_GNU)
-static inline bool isRedHat74()
+enum class LinuxDistribution { RedHat, CentOs, Other };
+
+static LinuxDistribution linuxDistribution()
+{
+ const QString &productType = QSysInfo::productType();
+ if (productType == QLatin1String("rhel"))
+ return LinuxDistribution::RedHat;
+ if (productType == QLatin1String("centos"))
+ return LinuxDistribution::CentOs;
+ return LinuxDistribution::Other;
+}
+
+static bool checkProductVersion(const QVersionNumber &minimum,
+ const QVersionNumber &excludedMaximum)
{
- if (QSysInfo::productType() != QLatin1String("rhel"))
- return false;
const QVersionNumber osVersion = QVersionNumber::fromString(QSysInfo::productVersion());
- return osVersion.isNull() || osVersion >= QVersionNumber(7, 4);
+ return osVersion.isNull() || (osVersion >= minimum && osVersion < excludedMaximum);
+}
+
+static inline bool needsGppInternalHeaders()
+{
+ const LinuxDistribution distro = linuxDistribution();
+ switch (distro) {
+ case LinuxDistribution::RedHat:
+ case LinuxDistribution::CentOs:
+ return checkProductVersion(QVersionNumber(7), QVersionNumber(8));
+ case LinuxDistribution::Other:
+ break;
+ }
+ return false;
}
#endif // Q_CC_GNU
@@ -260,9 +318,10 @@ QByteArrayList emulatedCompilerOptions()
#endif // NEED_CLANG_BUILTIN_INCLUDES
// Append the c++ include paths since Clang is unable to find <list> etc
- // on RHEL 7.4 with g++ 6.3. A fix for this has been added to Clang 5.0,
- // so, the code can be removed once Clang 5.0 is the minimum version.
- if (isRedHat74()) {
+ // on RHEL 7 with g++ 6.3 or CentOS 7.2.
+ // A fix for this has been added to Clang 5.0, so, the code can be removed
+ // once Clang 5.0 is the minimum version.
+ if (needsGppInternalHeaders()) {
const HeaderPaths gppPaths = gppInternalIncludePaths(QStringLiteral("g++"));
for (const HeaderPath &h : gppPaths) {
if (h.path.contains("c++"))
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index ae6b2a68a..122e60e41 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -259,7 +259,9 @@ void SbkObjectTypeDealloc(PyObject* pyObj)
PyTypeObject *type = reinterpret_cast<PyTypeObject*>(pyObj);
PyObject_GC_UnTrack(pyObj);
+#ifndef Py_LIMITED_API
Py_TRASHCAN_SAFE_BEGIN(pyObj);
+#endif
if (sotp) {
if (sotp->user_data && sotp->d_func) {
sotp->d_func(sotp->user_data);
@@ -272,7 +274,9 @@ void SbkObjectTypeDealloc(PyObject* pyObj)
delete sotp;
sotp = nullptr;
}
+#ifndef Py_LIMITED_API
Py_TRASHCAN_SAFE_END(pyObj);
+#endif
}
PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
diff --git a/sources/shiboken2/libshiboken/bufferprocs27.h b/sources/shiboken2/libshiboken/bufferprocs27.h
index 83c4a4750..6fc7a3ece 100644
--- a/sources/shiboken2/libshiboken/bufferprocs27.h
+++ b/sources/shiboken2/libshiboken/bufferprocs27.h
@@ -38,35 +38,36 @@
****************************************************************************/
/*
-PSF LICENSE AGREEMENT FOR PYTHON 3.6.5¶
+PSF LICENSE AGREEMENT FOR PYTHON 3.7.0
+
1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
the Individual or Organization ("Licensee") accessing and otherwise using Python
- 3.6.2 software in source or binary form and its associated documentation.
+ 3.7.0 software in source or binary form and its associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF hereby
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
analyze, test, perform and/or display publicly, prepare derivative works,
- distribute, and otherwise use Python 3.6.2 alone or in any derivative
+ distribute, and otherwise use Python 3.7.0 alone or in any derivative
version, provided, however, that PSF's License Agreement and PSF's notice of
- copyright, i.e., "Copyright © 2001-2017 Python Software Foundation; All Rights
- Reserved" are retained in Python 3.6.2 alone or in any derivative version
+ copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights
+ Reserved" are retained in Python 3.7.0 alone or in any derivative version
prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on or
- incorporates Python 3.6.2 or any part thereof, and wants to make the
+ incorporates Python 3.7.0 or any part thereof, and wants to make the
derivative work available to others as provided herein, then Licensee hereby
agrees to include in any such work a brief summary of the changes made to Python
- 3.6.2.
+ 3.7.0.
-4. PSF is making Python 3.6.2 available to Licensee on an "AS IS" basis.
+4. PSF is making Python 3.7.0 available to Licensee on an "AS IS" basis.
PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
- USE OF PYTHON 3.6.2 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
+ USE OF PYTHON 3.7.0 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
-5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.6.2
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.7.0
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
- MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.6.2, OR ANY DERIVATIVE
+ MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.7.0, OR ANY DERIVATIVE
THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material breach of
@@ -78,7 +79,7 @@ PSF LICENSE AGREEMENT FOR PYTHON 3.6.5¶
trademark sense to endorse or promote products or services of Licensee, or any
third party.
-8. By copying, installing or otherwise using Python 3.6.2, Licensee agrees
+8. By copying, installing or otherwise using Python 3.7.0, Licensee agrees
to be bound by the terms and conditions of this License Agreement.
*/
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..8f14c853a 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
@@ -289,83 +288,6 @@ typedef struct _methoddescr PyMethodDescrObject;
/*****************************************************************************
*
- * RESOLVED: pystate.h
- *
- */
-
-/*
- * pystate provides the data structure that is needed for the trashcan
- * algorithm. Unfortunately, it is not included in the limited API.
- * We have two options:
- *
- * (1) ignore trashcan and live without secured deeply nested structures,
- * (2) maintain the structure ourselves and make sure it does not change.
- *
- * I have chosen the second option.
- *
- * When a new python version appears, you need to check compatibility of
- * the PyThreadState structure (pystate.h) and the trashcan macros at the
- * end of object.h .
- */
-
-#ifdef Py_LIMITED_API
-
-#define Py_TRASH_MIN_COMPATIBLE 0x03020400
-#define Py_TRASH_MAX_COMPATIBLE 0x0307FFFF
-
-#if PY_VERSION_HEX >= Py_TRASH_MIN_COMPATIBLE && \
- PY_VERSION_HEX <= Py_TRASH_MAX_COMPATIBLE
-typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
-
-// This structure has the trashcan variables since Python 3.2.4.
-// We renamed all but the trashcan fields to make sure that we don't use
-// anything else somewhere.
-
-typedef struct _ts {
- struct _ts *Pep_prev;
- struct _ts *Pep_next;
- PyInterpreterState *Pep_interp;
-
- struct _frame *Pep_frame;
- int Pep_recursion_depth;
- char Pep_overflowed;
- char Pep_recursion_critical;
-
- int Pep_tracing;
- int Pep_use_tracing;
-
- Py_tracefunc Pep_c_profilefunc;
- Py_tracefunc Pep_c_tracefunc;
- PyObject *Pep_c_profileobj;
- PyObject *Pep_c_traceobj;
-
- PyObject *Pep_curexc_type;
- PyObject *Pep_curexc_value;
- PyObject *Pep_curexc_traceback;
-
- PyObject *Pep_exc_type;
- PyObject *Pep_exc_value;
- PyObject *Pep_exc_traceback;
-
- PyObject *Pep_dict;
-
- int Pep_gilstate_counter;
-
- PyObject *Pep_async_exc;
- long Pep_thread_id;
- // These two variables only are of interest to us.
- int trash_delete_nesting;
- PyObject *trash_delete_later;
- // Here we cut away the rest of the reduced structure.
-} PyThreadState;
-#else
-#error *** Please check compatibility of the trashcan code, see Pep.h ***
-#endif
-
-#endif // Py_LIMITED_API
-
-/*****************************************************************************
- *
* RESOLVED: pythonrun.h
*
*/
diff --git a/sources/shiboken2/libshiboken/qt_attribution.json b/sources/shiboken2/libshiboken/qt_attribution.json
index a90cc604b..14695a4d2 100644
--- a/sources/shiboken2/libshiboken/qt_attribution.json
+++ b/sources/shiboken2/libshiboken/qt_attribution.json
@@ -5,8 +5,8 @@
"QtUsage": "Used for Qt for Python in the signature extension.",
"Description": "Qt for Python is an add-on for Python. The libshiboken packages of PySide uses certain parts of the source files (typespec.cpp, typespec.h, bufferprocs27.cpp, bufferprocs27.h). See the folder sources/shiboken2/libshiboken .",
"Homepage": "http://www.python.org/",
- "Version": "3.6.5",
- "License": "PSF LICENSE AGREEMENT FOR PYTHON 3.6.5",
+ "Version": "3.7.0",
+ "License": "PSF LICENSE AGREEMENT FOR PYTHON 3.7.0",
"LicenseFile": "bufferprocs27.h",
"Copyright": "© Copyright 2001-2018, Python Software Foundation."
}
diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp
index 5f753293c..119591215 100644
--- a/sources/shiboken2/libshiboken/sbkenum.cpp
+++ b/sources/shiboken2/libshiboken/sbkenum.cpp
@@ -312,11 +312,15 @@ void SbkEnumTypeDealloc(PyObject* pyObj)
SbkEnumType* sbkType = reinterpret_cast<SbkEnumType*>(pyObj);
PyObject_GC_UnTrack(pyObj);
+#ifndef Py_LIMITED_API
Py_TRASHCAN_SAFE_BEGIN(pyObj);
+#endif
if (PepType_SETP(sbkType)->converter) {
Shiboken::Conversions::deleteConverter(PepType_SETP(sbkType)->converter);
}
+#ifndef Py_LIMITED_API
Py_TRASHCAN_SAFE_END(pyObj);
+#endif
}
PyObject* SbkEnumTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)