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

Unicode Decode Errror on windows #11

Open
PelzKo opened this issue Jul 11, 2022 · 4 comments
Open

Unicode Decode Errror on windows #11

PelzKo opened this issue Jul 11, 2022 · 4 comments

Comments

@PelzKo
Copy link

PelzKo commented Jul 11, 2022

On windows I have the following stacktrace when initializing Goslin (sorry for the formatting, it didnt manage to paste it and keep the new lines any other way):

Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Konstantin\Programmierung\lipid-librarian\src\lipid_librarian\__init__.py", line 38, in <module>
goslin_converter = goslin_init()
File "C:\Users\Konstantin\Programmierung\lipid-librarian\src\lipid_librarian\__init__.py", line 27, in goslin_init
return LipidParser()
File "C:\Users\Konstantin\Programmierung\lipid-librarian\venv\lib\site-packages\pygoslin\parser\Parser.py", line 114, in __init__
self.parser_list = [ShorthandParser(), GoslinParser(), FattyAcidParser(), LipidMapsParser(), SwissLipidsParser(), HmdbParser()]
File "C:\Users\Konstantin\Programmierung\lipid-librarian\venv\lib\site-packages\pygoslin\parser\Parser.py", line 79, in __init__
super().__init__(self.event_handler, file_name, Parser.DEFAULT_QUOTE)
File "C:\Users\Konstantin\Programmierung\lipid-librarian\venv\lib\site-packages\pygoslin\parser\ParserCommon.py", line 132, in __init__
rules = Parser.extract_text_based_rules(grammar_filename, self.quote)
File "C:\Users\Konstantin\Programmierung\lipid-librarian\venv\lib\site-packages\pygoslin\parser\ParserCommon.py", line 297, in extract_text_based_rules
grammar = infile.read() + "\n";
File "C:\Users\Konstantin\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 9820: character maps to <undefined>

I think that can be fixed by editing this line (and all other lines which read files) and specifying the encoding to UTF-8 like here

with open(grammar_filename, mode = "rt") as infile:

@PelzKo
Copy link
Author

PelzKo commented Jul 14, 2022

@dominik-kopczynski

@nilshoffmann
Copy link
Member

Fix and PR are in progress #12

@PelzKo
Copy link
Author

PelzKo commented Aug 12, 2022

This issue is solved, thank you for your help! Could you release it onto PyPi?

@chrispook
Copy link

chrispook commented Jan 9, 2023

This issue is solved, thank you for your help! Could you release it onto PyPi?

I have installed PyGoslin 2.0.2 using pip install pygoslin and this bug is still present. I am running Anaconda and Python 3.9.7.

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

3 participants