##// END OF EJS Templates
extensions: address ast deprecations introduced in Python 3.12...
Mads Kiilerich -
r51648:b9eb65a1 stable
parent child Browse files
Show More
@@ -885,16 +885,31 b' def _disabledcmdtable(path):'
885 with open(path, b'rb') as src:
885 with open(path, b'rb') as src:
886 root = ast.parse(src.read(), path)
886 root = ast.parse(src.read(), path)
887 cmdtable = {}
887 cmdtable = {}
888
889 # Python 3.12 started removing Bytes and Str and deprecate harder
890 use_constant = 'Bytes' not in vars(ast)
891
888 for node in _walkcommand(root):
892 for node in _walkcommand(root):
889 if not node.args:
893 if not node.args:
890 continue
894 continue
891 a = node.args[0]
895 a = node.args[0]
892 if isinstance(a, ast.Str):
896 if use_constant: # Valid since Python 3.8
893 name = pycompat.sysbytes(a.s)
897 if isinstance(a, ast.Constant):
894 elif isinstance(a, ast.Bytes):
898 if isinstance(a.value, str):
895 name = a.s
899 name = pycompat.sysbytes(a.value)
896 else:
900 elif isinstance(a.value, bytes):
897 continue
901 name = a.value
902 else:
903 continue
904 else:
905 continue
906 else: # Valid until 3.11
907 if isinstance(a, ast.Str):
908 name = pycompat.sysbytes(a.s)
909 elif isinstance(a, ast.Bytes):
910 name = a.s
911 else:
912 continue
898 cmdtable[name] = (None, [], b'')
913 cmdtable[name] = (None, [], b'')
899 return cmdtable
914 return cmdtable
900
915
General Comments 0
You need to be logged in to leave comments. Login now