aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-05-04 17:38:04 +0200
committerChristian Tismer <tismer@stackless.com>2020-05-16 15:05:44 +0200
commitcde603ba2c4fe7db1711aaf033f796112a840e7d (patch)
tree86419ff84b2926399c3b54faa154a8efa3a75e78 /sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
parenta49bc6164a95494b914d1428507e10ec16888229 (diff)
Implement __qualname__ and correct __module__ for classes
PyType_FromSpec breaks the name "A.B.C.D" in module "A.B.C" and name = qualname = "D". We fix that for PySide: module = "A.B" qualname = "C.D" name = "D" and for other prefixes like Shiboken: module = "A" qualname = "B.C.D" name = "D" This had quite some impact on the signature modules. Change-Id: Ie94971ba737107b15adbfc2517e1ed32b65fda39 Fixes: PYSIDE-1286 Task-number: PYSIDE-15 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py')
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index 8d970956b..2053c3e9d 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -165,6 +165,11 @@ def try_to_guess(thing, valtype):
return ret
return None
+def get_name(thing):
+ if isinstance(thing, type):
+ return getattr(thing, "__qualname__", thing.__name__)
+ else:
+ return thing.__name__
def _resolve_value(thing, valtype, line):
if thing in ("0", "None") and valtype:
@@ -172,7 +177,7 @@ def _resolve_value(thing, valtype, line):
return None
map = type_map[valtype]
# typing.Any: '_SpecialForm' object has no attribute '__name__'
- name = map.__name__ if hasattr(map, "__name__") else str(map)
+ name = get_name(map) if hasattr(map, "__name__") else str(map)
thing = "zero({})".format(name)
if thing in type_map:
return type_map[thing]
@@ -212,7 +217,8 @@ def to_string(thing):
return thing
if hasattr(thing, "__name__"):
dot = "." in str(thing)
- return thing.__module__ + "." + thing.__name__ if dot else thing.__name__
+ name = get_name(thing)
+ return thing.__module__ + "." + name if dot else name
# Note: This captures things from the typing module:
return str(thing)