Show More
@@ -885,10 +885,25 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] | |
|
896 | if use_constant: # Valid since Python 3.8 | |||
|
897 | if isinstance(a, ast.Constant): | |||
|
898 | if isinstance(a.value, str): | |||
|
899 | name = pycompat.sysbytes(a.value) | |||
|
900 | elif isinstance(a.value, bytes): | |||
|
901 | name = a.value | |||
|
902 | else: | |||
|
903 | continue | |||
|
904 | else: | |||
|
905 | continue | |||
|
906 | else: # Valid until 3.11 | |||
892 | if isinstance(a, ast.Str): |
|
907 | if isinstance(a, ast.Str): | |
893 | name = pycompat.sysbytes(a.s) |
|
908 | name = pycompat.sysbytes(a.s) | |
894 | elif isinstance(a, ast.Bytes): |
|
909 | elif isinstance(a, ast.Bytes): |
General Comments 0
You need to be logged in to leave comments.
Login now