stubtest crashes when a referenced module is a DLL, as it seemingly tries to parse the .dll's content as text.
PS C:\Users\Avasam\Documents\Git\typeshed> python .\tests\stubtest_third_party.py pywin32
pywin32... fail
C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\Scripts\pip.exe install pywin32[]==304.* mypy==0.982
MYPYPATH=C:\Users\Avasam\Documents\Git\typeshed\stubs\pywin32 C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\Scripts\python.exe -m mypy.stubtest --custom-typeshed-dir C:\Users\Avasam\Documents\Git\typeshed pythonwin win32 win32comext pythoncom _win32typing --allowlist C:\Users\Avasam\Documents\Git\typeshed\stubs\pywin32\@tests\stubtest_allowlist.txt
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\tokenize.py", line 330, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\lib\site-packages\mypy\stubtest.py", line 1713, in <module>
sys.exit(main())
File "C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\lib\site-packages\mypy\stubtest.py", line 1709, in main
return test_stubs(parse_options(sys.argv[1:]))
File "C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\lib\site-packages\mypy\stubtest.py", line 1605, in test_stubs
print(error.get_description(concise=args.concise))
File "C:\Users\Avasam\AppData\Local\Temp\tmp3yxfa81_\lib\site-packages\mypy\stubtest.py", line 138, in get_description
runtime_line = inspect.getsourcelines(self.runtime_object)[1]
File "C:\Program Files\Python39\lib\inspect.py", line 1006, in getsourcelines
lines, lnum = findsource(object)
File "C:\Program Files\Python39\lib\inspect.py", line 831, in findsource
lines = linecache.getlines(file, module.__dict__)
File "C:\Program Files\Python39\lib\linecache.py", line 46, in getlines
return updatecache(filename, module_globals)
File "C:\Program Files\Python39\lib\linecache.py", line 136, in updatecache
with tokenize.open(fullname) as fp:
File "C:\Program Files\Python39\lib\tokenize.py", line 394, in open
encoding, lines = detect_encoding(buffer.readline)
File "C:\Program Files\Python39\lib\tokenize.py", line 371, in detect_encoding
encoding = find_cookie(first)
File "C:\Program Files\Python39\lib\tokenize.py", line 335, in find_cookie
raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\Avasam\\AppData\\Local\\Temp\\tmp3yxfa81_\\lib\\site-packages\\pywin32_system32\\pywintypes39.dll'
The easiest way to reproduce would be to use the pywin32 stubs from typeshed as an example. It has references to pywintypes39.dll and pythoncom39.dll. Make sure that METADATA.toml has:
Crash Report
stubtest crashes when a referenced module is a DLL, as it seemingly tries to parse the
.dll's content as text.Traceback
To Reproduce
The easiest way to reproduce would be to use the pywin32 stubs from typeshed as an example. It has references to
pywintypes39.dllandpythoncom39.dll. Make sure thatMETADATA.tomlhas:python .\tests\stubtest_third_party.py pywin32Your Environment
mypy.ini(and other config files): (see above)