aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py50
1 files changed, 20 insertions, 30 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index 1d4dadc55..9674ca769 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -37,6 +37,7 @@
##
#############################################################################
+import ast
import enum
import functools
import keyword
@@ -94,31 +95,32 @@ def _get_flag_enum_option():
flag = True
elif opt in ("no", "off", "false"):
flag = False
- elif opt.isnumeric():
- flag = bool(int(opt))
+ else:
+ # instead of a simple int() conversion, let's allow for "0xf" or "0b1111"
+ try:
+ flag = ast.literal_eval(opt)
+ except Exception:
+ flag = True
elif hasattr(sys, sysname):
- flag = bool(getattr(sys, sysname))
+ flag = getattr(sys, sysname)
+ if not isinstance(flag, int):
+ flag = True
+ p = f"\n *** Python is at version {'.'.join(map(str, pyminver))} now."
# PYSIDE-1797: Emit a warning when we may remove pep384_issue33738.cpp
if pyminver and pyminver >= (3, 8):
- warnings.warn(f"\n *** Python is at version {'.'.join(map(str, pyminver))} now. "
- f"The file pep384_issue33738.cpp should be removed ASAP! ***")
+ warnings.warn(f"{p} The file pep384_issue33738.cpp should be removed ASAP! ***")
+ # _PepUnicode_AsString: Fix a broken promise
+ if pyminver and pyminver >= (3, 10):
+ warnings.warn(f"{p} _PepUnicode_AsString can now be replaced by PyUnicode_AsUTF8! ***")
# PYSIDE-1960: Emit a warning when we may remove pep384_issue33738.cpp
if pyminver and pyminver >= (3, 11):
- warnings.warn(f"\n *** Python is at version {'.'.join(map(str, pyminver))} now. "
- f"The files bufferprocs_py37.(cpp|h) should be removed ASAP! ***")
- # PYSIDE-1735: Emit a warning when we may update enum_310.py
- if pymaxver and pymaxver > (3, 10):
- if sys.version_info >= (3, 11, 0) and sys.version_info.releaselevel == "final":
- warnings.warn(f"\n *** Python is at version {'.'.join(map(str, pymaxver))} now. "
- f"Please check if enum_310.py should be updated! ***")
- # PYSIDE-1735: Emit a warning when we may update enum_310.py
+ warnings.warn(f"{p} The files bufferprocs_py37.(cpp|h) should be removed ASAP! ***")
+ # PYSIDE-1735: Emit a warning when we should maybe evict forgiveness mode
if ver[:2] >= (7, 0):
- warnings.warn(f"\n *** PySide is at version {'.'.join(map(str, ver[:2]))} now. "
- f"Please drop the forgiving Enum behavior in `mangled_type_getattro` ***")
- # modify the sys attribute to bool
+ warnings.warn(f"{p} Please drop Enum forgiveness mode in `mangled_type_getattro` ***")
+ # normalize the sys attribute
setattr(sys, sysname, flag)
- # modify the env attribute to "0" or "1"
- os.environ[envname] = str(int(flag))
+ os.environ[envname] = str(flag)
return flag
@@ -434,18 +436,6 @@ def handle_retvar(obj):
def calculate_props(line):
- # PYSIDE-1735: QFlag is now divided into fields for future Python Enums, like
- # "PySide.QtCore.^^Qt.ItemFlags^^Qt.ItemFlag^^"
- # Resolve that until Enum is finally settled.
- while "^^" in line:
- parts = line.split("^^", 3)
- selected = EnumSelect.SELECTION
- line = parts[0] + parts[selected.value] + parts[3]
- if selected is EnumSelect.NEW:
- _old, _new = EnumSelect.OLD.value, EnumSelect.NEW.value
- line = re.sub(rf"\b{parts[_old]}\b", parts[_new], line)
- type_map[parts[_old]] = parts[_new]
-
parsed = SimpleNamespace(**_parse_line(line.strip()))
arglist = parsed.arglist
annotations = {}