$ echo '中=1' | yapf
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/yapflib/pytree_utils.py", line 115, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/driver.py", line 104, in parse_string
return self.parse_tokens(tokens, debug)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/driver.py", line 72, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/parse.py", line 116, in addtoken
ilabel = self.classify(type, value, context)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/parse.py", line 172, in classify
raise ParseError("bad token", type, value, context)
lib2to3.pgen2.parse.ParseError: bad token: type=58, value='中', context=('', (1, 0))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/yapflib/yapf_api.py", line 129, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/yapflib/pytree_utils.py", line 121, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/driver.py", line 104, in parse_string
return self.parse_tokens(tokens, debug)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/driver.py", line 72, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/parse.py", line 116, in addtoken
ilabel = self.classify(type, value, context)
File "/usr/local/miniconda3/lib/python3.7/lib2to3/pgen2/parse.py", line 172, in classify
raise ParseError("bad token", type, value, context)
lib2to3.pgen2.parse.ParseError: bad token: type=58, value='中', context=('', (1, 0))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/miniconda3/bin/yapf", line 10, in <module>
sys.exit(run_main())
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/__init__.py", line 313, in run_main
sys.exit(main(sys.argv))
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/__init__.py", line 183, in main
verify=args.verify)
File "/usr/local/miniconda3/lib/python3.7/site-packages/yapf/yapflib/yapf_api.py", line 131, in FormatCode
raise parse.ParseError(filename + ': ' + e.message)
AttributeError: 'ParseError' object has no attribute 'message'```
Python3 already support non-ASCII identifiers, pep-3131. But yapf fails to parse.
See example below,
中is a non-ASCII token.