Skip to content

Fix error in Windows in zh_CN locale - #51

Merged
gnikit merged 1 commit into
fortran-lang:masterfrom
BeiyanYunyi:patch-1
Feb 23, 2022
Merged

gnikit merged 1 commit into
fortran-lang:masterfrom
BeiyanYunyi:patch-1

Conversation

@BeiyanYunyi

Copy link
Copy Markdown

By default python in Windows in zh_CN will use GBK to open files, since we're using UTF-8 now, it will throw error like this:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\fortls.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\fortls\__init__.py", line 56, in main
    LangServer(
  File "C:\Program Files\Python310\lib\site-packages\fortls\langserver.py", line 119, in __init__
    ) = load_intrinsics()
  File "C:\Program Files\Python310\lib\site-packages\fortls\intrinsics.py", line 168, in load_intrinsics
    intrin_file = json.load(fid)
  File "C:\Program Files\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 11899: illegal multibyte sequence

By default python in Windows in zh_CN will use GBK to open files, since we're using UTF-8 now, it will throw error like this:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\fortls.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\fortls\__init__.py", line 56, in main
    LangServer(
  File "C:\Program Files\Python310\lib\site-packages\fortls\langserver.py", line 119, in __init__
    ) = load_intrinsics()
  File "C:\Program Files\Python310\lib\site-packages\fortls\intrinsics.py", line 168, in load_intrinsics
    intrin_file = json.load(fid)
  File "C:\Program Files\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 11899: illegal multibyte sequence
@codecov

codecov Bot commented Feb 23, 2022

Copy link
Copy Markdown

Codecov Report

Merging #51 (a3ffc88) into master (914ff47) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #51   +/-   ##
=======================================
  Coverage   81.34%   81.34%           
=======================================
  Files           9        9           
  Lines        4305     4305           
=======================================
  Hits         3502     3502           
  Misses        803      803           
Impacted Files Coverage Δ
fortls/intrinsics.py 91.85% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 914ff47...a3ffc88. Read the comment docs.

@gnikit

gnikit commented Feb 23, 2022

Copy link
Copy Markdown
Member

@lixiang810 Nice catch!

@gnikit
gnikit merged commit 372b461 into fortran-lang:master Feb 23, 2022
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

Successfully merging this pull request may close these issues.

2 participants