aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
index 5171d59e9..7a0871ee7 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
@@ -1,6 +1,9 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+# flake8: noqa F:821
+# flake8: noqa F:401
+
"""
__feature__.py (renamed to feature.py)
@@ -15,7 +18,7 @@ The normal usage is like
Alternatively, there is the `set_selection` function which uses select_id's
and takes an optional `mod_name` parameter.
-The select id `-1` has the spectial meaning "ignore this module".
+The select id `-1` has the special meaning "ignore this module".
"""
import inspect
@@ -80,6 +83,7 @@ None to indicate that a normal import should be performed, and
All these variables are transparently kept in module `builtins`.
"""
+
def feature_import(name, *args, **kwargs):
# PYSIDE-1368: The `__name__` attribute does not need to exist in all modules.
# PYSIDE-1398: sys._getframe(1) may not exist when embedding.
@@ -110,8 +114,10 @@ def feature_import(name, *args, **kwargs):
# Redirect to the original import
return None
+
_is_initialized = False
+
def __init__():
global _is_initialized
if not _is_initialized:
@@ -132,9 +138,12 @@ def feature_imported(module):
A module that uses PySide has a switching default of 0 = "no feature".
Otherwise the default is -1 = "ignore this module".
"""
- name = module.__name__
- if name not in pyside_feature_dict:
- pyside_feature_dict[name] = 0 if _mod_uses_pyside(module) else -1
+
+ # PYSIDE-1368: The `__name__` attribute does not need to exist in all modules.
+ if hasattr(module, "__name__"):
+ name = module.__name__
+ if name not in pyside_feature_dict:
+ pyside_feature_dict[name] = 0 if _mod_uses_pyside(module) else -1
def _mod_uses_pyside(module):
@@ -152,6 +161,15 @@ def _mod_uses_pyside(module):
except OSError:
# this is a module withot source file
return False
+ except SyntaxError:
+ # PYSIDE-2189: A UnicodeError happens in tokenize.py in find_cookie
+ # which is then creating a SyntaxError in inspect.
+ # This is undocumented and a Python error, seen in Python 3.10.2 on Windows,
+ # importing `pythoncom` of the win32 package.
+ return False
+ except Exception:
+ # PYSIDE-2393: pytest behaves weird when allowing any other error.
+ return False
return "PySide6" in source
@@ -170,6 +188,7 @@ def set_selection(select_id, mod_name=None):
sys.modules["PySide6.QtCore"].__init_feature__()
return _current_selection(flag)
+
# The set_section(0) case seems to be unsafe. We will migrate to
# use the opaque feature.reset() call in all test cases.
def reset():