aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp1
-rw-r--r--sources/shiboken2/libshiboken/embed/signature_bootstrap.py42
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp4
3 files changed, 25 insertions, 22 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 7ac7fada2..afca7fa08 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -804,6 +804,7 @@ static PyObject *_setupNew(SbkObject *self, PyTypeObject *subtype)
d->parentInfo = nullptr;
d->referredObjects = nullptr;
d->cppObjectCreated = 0;
+ d->isQAppSingleton = 0;
self->ob_dict = nullptr;
self->weakreflist = nullptr;
self->d = d;
diff --git a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
index 902864267..b64131c15 100644
--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
+++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
@@ -62,6 +62,11 @@ recursion_trap = 0
# Python 2 is not able to import when the extension import is still active.
# Phase 1 simply defines the functions, which will be used in Phase 2.
+import sys
+if sys.version_info[0] >= 3:
+ from importlib.machinery import ModuleSpec
+
+
def bootstrap():
import sys
import os
@@ -204,31 +209,28 @@ class EmbeddableZipImporter(object):
return None
self.zfile = zip_file
- self._path2mod = {_.filename : p2m(_.filename) for _ in zip_file.filelist}
- self._mod2path = {_[1] : _[0] for _ in self._path2mod.items()}
+ self._mod2path = {p2m(_.filename) : _.filename for _ in zip_file.filelist}
- def find_module(self, fullname, path):
- return self if self._mod2path.get(fullname) else None
+ def find_spec(self, fullname, path, target=None):
+ path = self._mod2path.get(fullname)
+ return ModuleSpec(fullname, self) if path else None
- def load_module(self, fullname):
- import importlib
- import sys
+ def create_module(self, spec):
+ return None
- filename = self._mod2path.get(fullname)
- if filename not in self._path2mod:
- raise ImportError(fullname)
- module_spec = importlib.machinery.ModuleSpec(fullname, None)
- new_module = importlib.util.module_from_spec(module_spec)
+ def exec_module(self, module):
+ fullname = module.__spec__.name
+ filename = self._mod2path[fullname]
with self.zfile.open(filename, "r") as f: # "rb" not for zipfile
- exec(f.read(), new_module.__dict__)
- new_module.__file__ = filename
- new_module.__loader__ = self
+ codeob = compile(f.read(), filename, "exec")
+ exec(codeob, module.__dict__)
+ module.__file__ = filename
+ module.__loader__ = self
if filename.endswith("/__init__.py"):
- new_module.__path__ = []
- new_module.__package__ = fullname
+ module.__path__ = []
+ module.__package__ = fullname
else:
- new_module.__package__ = fullname.rpartition('.')[0]
- sys.modules[fullname] = new_module
- return new_module
+ module.__package__ = fullname.rpartition('.')[0]
+ sys.modules[fullname] = module
# eof
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
index 66df0fd94..fb28d883f 100644
--- a/sources/shiboken2/libshiboken/pep384impl.cpp
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp
@@ -751,7 +751,7 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
#endif // IS_PY2
Shiboken::AutoDecRef privateobj(PyObject_GetAttr(
reinterpret_cast<PyObject *>(Py_TYPE(self)), Shiboken::PyMagicName::name()));
-#ifndef Py_LIMITED_API
+#ifdef IS_PY2
return _Py_Mangle(privateobj, name);
#else
// PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always.
@@ -789,7 +789,7 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
if (amount > big_stack)
free(resbuf);
return result;
-#endif // else Py_LIMITED_API
+#endif // else IS_PY2
}
/*****************************************************************************