diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-16 23:20:27 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-19 06:53:57 +0100 |
commit | 1323cd8ac47060bb70e54103c0a4e18d3886e703 (patch) | |
tree | d5d70d3885ed80267b2f67e7442e2d8415d1babc /sources | |
parent | 4d12849bc72cd54f4aec3118f9daf89af156e2c2 (diff) |
Replace imp by importlib
Getting rid of the DeprecationWarning
Change-Id: I86370c266d502fcd0fb61a9945770354b8f87142
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/tests/QtGui/pyside_reload_test.py | 8 | ||||
-rw-r--r-- | sources/shiboken2/data/shiboken_helpers.cmake | 17 |
2 files changed, 15 insertions, 10 deletions
diff --git a/sources/pyside2/tests/QtGui/pyside_reload_test.py b/sources/pyside2/tests/QtGui/pyside_reload_test.py index c3e8c218e..cd045047a 100644 --- a/sources/pyside2/tests/QtGui/pyside_reload_test.py +++ b/sources/pyside2/tests/QtGui/pyside_reload_test.py @@ -41,8 +41,8 @@ sys.path.append(workdir) def reload_module(moduleName): if py3k.IS_PY3K: - import imp - imp.reload(moduleName) + import importlib + importlib.reload(moduleName) else: reload(moduleName) @@ -53,8 +53,8 @@ def increment_module_value(): modfile.close() if not sys.dont_write_bytecode: if py3k.IS_PY3K: - import imp - cacheFile = imp.cache_from_source(dst) + import importlib.util + cacheFile = importlib.util.cache_from_source(dst) else: cacheFile = dst + 'c' os.remove(cacheFile) diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake index 8111fa61f..5d7ff56bb 100644 --- a/sources/shiboken2/data/shiboken_helpers.cmake +++ b/sources/shiboken2/data/shiboken_helpers.cmake @@ -221,15 +221,20 @@ macro(set_quiet_build) endmacro() macro(get_python_extension_suffix) - # Result of imp.get_suffixes() depends on the platform, but generally looks something like: - # [('.cpython-34m-x86_64-linux-gnu.so', 'rb', 3), ('.cpython-34m.so', 'rb', 3), - # ('.abi3.so', 'rb', 3), ('.so', 'rb', 3), ('.py', 'r', 1), ('.pyc', 'rb', 2)] - # We pick the first most detailed one, strip of the file extension part. + # Result of importlib.machinery.EXTENSION_SUFFIXES depends on the platform, + # but generally looks something like: + # ['.cpython-38-x86_64-linux-gnu.so', '.abi3.so', '.so'] + # We pick the first most detailed one. execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "if True: - import imp, re - first_suffix = imp.get_suffixes()[0][0] + import re + try: + from importlib import machinery + first_suffix = machinery.EXTENSION_SUFFIXES[0] + except AttributeError: + import imp + first_suffix = imp.get_suffixes()[0][0] res = re.search(r'^(.+)\\.', first_suffix) if res: first_suffix = res.group(1) |