Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When executing the mamba in non-utf-8 environment would cause exception #118

Open
cmtony opened this issue Jul 2, 2018 · 0 comments
Open

Comments

@cmtony
Copy link

cmtony commented Jul 2, 2018

with open(path) as f:

As title, when I executed the mamba in non-utf-8 environment, it would cause exception like:

Traceback (most recent call last):
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\Scripts\mamba.exe\__main__.py", line 9, in <module>
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\cli.py", line 18, in main
    runner.run()
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\runners.py", line 29, in run
    modules = self.example_collector.modules()
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\example_collector.py", line 25, in modules
    with self._load_module_from(path) as module:
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\example_collector.py", line 57, in _load_module_from
    yield self._module_from_ast(name, path)
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\example_collector.py", line 60, in _module_from_ast
    tree = self._parse_and_transform_ast(path)
  File "C:\Users\tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mamba\example_collector.py", line 82, in _parse_and_transform_ast
    tree = ast.parse(f.read(), filename=path)

UnicodeDecodeError: 'cp950' codec can't decode byte 0xe6 in position 1602: illegal multibyte sequence

To solve this issue, I've tried to update this line(mamba/mamba/example_collector.py, line 81) as below and it works:

    with open(path, encoding='utf-8') as f:

Could anyone please update the encoding to 'utf-8' in this file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant