Closed
Description
I was trying to generate stubs for sre_compile
and it fails with:
$ python stubgen.py --py2 sre_compile
.../2.7/lib/python2.7/sre_compile.py:0: error: encoding declaration in Unicode string
This is probably happening because ast27_parse_impl
converts source from bytes to string and tries to parse it without caring about source code encoding comment.
PEP 263 says:
If a Unicode string with a coding declaration is passed to
compile()
, aSyntaxError
will be raised.
One quick fix would be to remove such comment from source before it is passed to mypy.parse.parse()
in stubgen.py.
I am wondering if this is worth fixing? If yes, is the above the best way to do it.
Metadata
Metadata
Assignees
Labels
No labels