Modify python version check such that linters recognize it

This commit is contained in:
Omer Lubin 2024-10-18 15:43:19 +03:00
parent 3691e33a0f
commit a7ba97b065
4 changed files with 8 additions and 9 deletions

View File

@ -8,7 +8,7 @@ from .unicorn_const import (
__version__ = "%u.%u.%u" % (__MAJOR, __MINOR, __PATCH)
if _sys.version_info.major == 2:
from .unicorn_py2 import *
else:
if _sys.version_info >= (3,):
from .unicorn_py3 import *
else:
from .unicorn_py2 import *

View File

@ -23,8 +23,7 @@ ucsubclass = 0
if not hasattr(sys.modules[__name__], "__file__"):
__file__ = inspect.getfile(inspect.currentframe())
_python2 = sys.version_info[0] < 3
if _python2:
if sys.version_info < (3,):
range = xrange
_lib = { 'darwin': 'libunicorn.2.dylib',
@ -55,7 +54,7 @@ def _load_win_support(path):
ctypes.cdll.LoadLibrary(lib_file)
#print('SUCCESS')
_loaded_windows_dlls.add(dll)
except OSError as e:
except OSError:
#print('FAIL to load %s' %lib_file, e)
continue
@ -72,7 +71,7 @@ def _load_lib(path):
dll = ctypes.cdll.LoadLibrary(lib_file)
#print('SUCCESS')
return dll
except OSError as e:
except OSError:
#print('FAIL to load %s' %lib_file, e)
return None

View File

@ -104,7 +104,7 @@ def __load_uc_lib() -> ctypes.CDLL:
# - global load
# - python's lib directory
if sys.version_info.minor >= 12:
if sys.version_info >= (3, 12):
from importlib import resources
canonicals = resources.files('unicorn') / 'lib'

View File

@ -9,7 +9,7 @@ from unicorn import *
from unicorn.x86_const import *
if sys.version_info.major == 2:
if sys.version_info < (3,):
range = xrange