NiklasRosenstein / python-docspec

Docspec is a JSON object specification for representing API documentation of programming languages.
https://niklasrosenstein.github.io/python-docspec/
Other
16 stars 6 forks source link

UnicodeDecodeError #10

Closed nnnewb closed 3 years ago

nnnewb commented 3 years ago

https://github.com/NiklasRosenstein/docspec/blob/fb8069fbc3d266b8e5046fe3a728b4db8a7db1bd/docspec-python/src/docspec_python/__init__.py#L98

pydoc-markdown crash because of this line. open(f, encoding='utf-8') as fp: works for me.

Traceback (most recent call last):
  File "C:\Users\weakptr\scoop\apps\python37\3.7.9\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\weakptr\scoop\apps\python37\3.7.9\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\repos\NEMCore\venv\Scripts\pydoc-markdown.exe\__main__.py", line 7, in <module>
  File "d:\repos\nemcore\venv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "d:\repos\nemcore\venv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "d:\repos\nemcore\venv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "d:\repos\nemcore\venv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "d:\repos\nemcore\venv\lib\site-packages\pydoc_markdown\main.py", line 337, in cli
    session.render(pydocmd)
  File "d:\repos\nemcore\venv\lib\site-packages\pydoc_markdown\main.py", line 134, in render
    modules = config.load_modules()
  File "d:\repos\nemcore\venv\lib\site-packages\pydoc_markdown\__init__.py", line 134, in load_modules
    modules.extend(loader.load())
  File "d:\repos\nemcore\venv\lib\site-packages\docspec_python\__init__.py", line 82, in load_python_modules
    yield parse_python_module(filename, module_name=module_name, options=options)
  File "d:\repos\nemcore\venv\lib\site-packages\docspec_python\__init__.py", line 99, in parse_python_module
    return parse_python_module(fp, filename, module_name, options)
  File "d:\repos\nemcore\venv\lib\site-packages\docspec_python\__init__.py", line 103, in parse_python_module
    ast = parser.parse_to_ast(f.read(), filename)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 46: illegal multibyte sequence
NiklasRosenstein commented 3 years ago

Thanks for reporting @nnnewb. Is