Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
dont import sre_compile and sre_parse in Python 3.11+
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Sep 24, 2023
1 parent 9ae3904 commit 3acdc00
Showing 1 changed file with 49 additions and 47 deletions.
96 changes: 49 additions & 47 deletions sot/opcode_translator/skip_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import re
import selectors
import signal
import sre_compile
import sre_parse
import sys
import tempfile
import threading
Expand All @@ -45,6 +43,54 @@

from ..utils import log

NEED_SKIP_THIRD_PARTIY_MODULES = {
abc,
collections,
contextlib,
copy,
copyreg,
dataclasses,
enum,
functools,
google.protobuf,
importlib,
inspect,
linecache,
logging,
multiprocessing,
numpy,
operator,
os,
posixpath,
random,
re,
selectors,
signal,
tempfile,
threading,
tokenize,
traceback,
types,
typing,
unittest,
weakref,
_collections_abc,
_weakrefset,
decorator,
codecs,
uuid,
setuptools,
distutils,
warnings,
}

if sys.version_info < (3, 11):
import sre_compile
import sre_parse

NEED_SKIP_THIRD_PARTIY_MODULES.add(sre_compile)
NEED_SKIP_THIRD_PARTIY_MODULES.add(sre_parse)


def _strip_init_py(s):
return re.sub(r"__init__.py$", "", s)
Expand All @@ -54,51 +100,7 @@ def _module_dir(m: types.ModuleType):
return _strip_init_py(m.__file__)


skip_file_names = {
_module_dir(m)
for m in (
abc,
collections,
contextlib,
copy,
copyreg,
dataclasses,
enum,
functools,
google.protobuf,
importlib,
inspect,
linecache,
logging,
multiprocessing,
numpy,
operator,
os,
posixpath,
random,
re,
selectors,
sre_compile,
sre_parse,
signal,
tempfile,
threading,
tokenize,
traceback,
types,
typing,
unittest,
weakref,
_collections_abc,
_weakrefset,
decorator,
codecs,
uuid,
setuptools,
distutils,
warnings,
)
}
skip_file_names = {_module_dir(m) for m in NEED_SKIP_THIRD_PARTIY_MODULES}


sot_path = os.path.dirname(__file__).rpartition("/")[0] + "/"
Expand Down

0 comments on commit 3acdc00

Please sign in to comment.