aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-10-07 12:08:18 +0200
committerChristian Tismer <tismer@stackless.com>2020-10-07 13:18:49 +0200
commitd3b523ef428d299b4d6e860cfa282da942924cfa (patch)
tree22be311f7d37cd2355282088c3fdfcaf96fbd802
parent8bf602d7f5ac9ad6b12db35d3e9e5876014d860e (diff)
__feature__: avoid sys._geframe(1) error when embedding
Change-Id: Ife42d7a3f855816c66dcbd4b8062b72f947510e7 Fixes: PYSIDE-1398 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/__feature__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/__feature__.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/__feature__.py
index 64f654d30..ece3d2edb 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/__feature__.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/__feature__.py
@@ -104,7 +104,9 @@ Note: This are two imports.
# XXX build an improved C version? I guess not.
def _import(name, *args, **kwargs):
# PYSIDE-1368: The `__name__` attribute does not need to exist in all modules.
- importing_module = sys._getframe(1).f_globals.get("__name__", "__main__")
+ # PYSIDE-1398: sys._getframe(1) may not exist when embedding.
+ calling_frame = _cf = sys._getframe().f_back
+ importing_module = _cf.f_globals.get("__name__", "__main__") if _cf else "__main__"
existing = pyside_feature_dict.get(importing_module, 0)
if name == "__feature__" and args[2]: