-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Bug Report
Can't use stubgen in Windows if the source contains special characters not belonging to the current "code page".
To Reproduce
- In Windows, create a file
example.pywith UTF-8 encoding and the following contents:
def get_π():
return 3- Execute
stubgen -m example -o .
Expected Behavior
Should execute normally:
Processed 1 modules
Generated .\example.pyi
Actual Behavior
Error:
Traceback (most recent call last):
File "<env>\Scripts\stubgen-script.py", line 10, in <module>
sys.exit(main())
File "mypy\stubgen.py", line 1655, in main
File "mypy\stubgen.py", line 1533, in generate_stubs
File "mypy\stubgen.py", line 1489, in generate_stub_from_ast
File "<env>\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03c0' in position 8: character maps to <undefined>
Your Environment
- Mypy version used: 0.910
Notes
The problem seems to be this open here, without an encoding argument. Perhaps the encoding could be passed via command line argument, or via an environment variable?
danilomendesdias and billsioros