aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-08-30 12:07:30 +0200
committerChristian Tismer <tismer@stackless.com>2020-08-31 11:55:16 +0200
commit16edb30687582a0fd355b42cfc918a89dab2d858 (patch)
treeae1d88cbd0ae454da6d022d3f68ab17679245370
parent72aadf11a482acebf11d7658b7edb942d9995ff0 (diff)
signature: Avoid non-existent attributes in compiled code (Nuitka)
In standard Python, there is (yet) no attribute "__signature__". Nuitka, the compiler, knows that and raises an AttributeError without even trying. The workaround was simple: Use "eval". Change-Id: Ice9deccd7ba2fe4c376f0a151924a68f88ca020d Fixes: PYSIDE-829 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/pyside2/PySide2/__init__.py.in3
-rw-r--r--sources/shiboken2/libshiboken/embed/signature_bootstrap.py2
-rw-r--r--sources/shiboken2/shibokenmodule/__init__.py.in2
-rw-r--r--sources/shiboken2/tests/minimalbinding/brace_pattern_test.py2
-rw-r--r--sources/shiboken2/tests/samplebinding/pointerprimitivetype_test.py2
5 files changed, 6 insertions, 5 deletions
diff --git a/sources/pyside2/PySide2/__init__.py.in b/sources/pyside2/PySide2/__init__.py.in
index 5c33c57a0..94683b463 100644
--- a/sources/pyside2/PySide2/__init__.py.in
+++ b/sources/pyside2/PySide2/__init__.py.in
@@ -64,7 +64,8 @@ def _setupQtDirectories():
# Trigger signature initialization.
try:
- type.__signature__
+ # PYSIDE-829: Avoid non-existent attributes in compiled code (Nuitka).
+ eval("type.__signature__")
except AttributeError:
print(dedent('''\
{stars}
diff --git a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
index eb182d8c4..3a74bb42e 100644
--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
+++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py
@@ -73,7 +73,7 @@ def bootstrap():
if recursion_trap:
# we are probably called from outside, already
print("Recursion occurred in Bootstrap. Did you start by hand? Then it's ok.")
- print("But you should trigger start by 'type.__signature__', only!")
+ print("""But you should trigger start by 'eval("type.__signature__")', only!""")
recursion_trap += 1
@contextmanager
diff --git a/sources/shiboken2/shibokenmodule/__init__.py.in b/sources/shiboken2/shibokenmodule/__init__.py.in
index ed6ce5623..eb392e847 100644
--- a/sources/shiboken2/shibokenmodule/__init__.py.in
+++ b/sources/shiboken2/shibokenmodule/__init__.py.in
@@ -27,4 +27,4 @@ if sys.version_info[0] == 3:
from .shiboken2 import *
# Trigger signature initialization.
-type.__signature__
+eval("type.__signature__")
diff --git a/sources/shiboken2/tests/minimalbinding/brace_pattern_test.py b/sources/shiboken2/tests/minimalbinding/brace_pattern_test.py
index e48027d2a..bcaccac44 100644
--- a/sources/shiboken2/tests/minimalbinding/brace_pattern_test.py
+++ b/sources/shiboken2/tests/minimalbinding/brace_pattern_test.py
@@ -49,7 +49,7 @@ from shiboken_paths import init_paths
init_paths()
import shiboken2
-type.__signature__ # trigger bootstrap
+eval("type.__signature__") # trigger bootstrap
from shibokensupport.signature.lib.tool import build_brace_pattern
diff --git a/sources/shiboken2/tests/samplebinding/pointerprimitivetype_test.py b/sources/shiboken2/tests/samplebinding/pointerprimitivetype_test.py
index 9ce641f61..3abd01cd9 100644
--- a/sources/shiboken2/tests/samplebinding/pointerprimitivetype_test.py
+++ b/sources/shiboken2/tests/samplebinding/pointerprimitivetype_test.py
@@ -54,7 +54,7 @@ init_paths()
from sample import IntArray2, VirtualMethods
import shiboken2
-type.__signature__ # trigger init, which does not happen in tests
+eval("type.__signature__") # trigger init, which does not happen in tests
from shibokensupport.signature import typing