EconForge/dolo.py

Issue reading grammar on Windows

Mv77 opened this issue · 2 comments

Mv77 commented

Hi,

I'm trying to work with dolo in my Windows machine, but the latest version (0.4.9.15) does not work. Running import dolo causes the following error

>>> import dolo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mateo\Anaconda3\lib\site-packages\dolo\__init__.py", line 3, in <module>
    import dolang
  File "C:\Users\mateo\Anaconda3\lib\site-packages\dolang\__init__.py", line 4, in <module>
    from dolang.grammar import parse_string
  File "C:\Users\mateo\Anaconda3\lib\site-packages\dolang\grammar.py", line 29, in <module>
    grammar_0 = open(DATA_PATH, "rt").read()
  File "C:\Users\mateo\Anaconda3\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 0x9d in position 1179: character maps to <undefined>

What seems to be happening is that Windows tries to open the grammar file using the encoding cp1252 by default, and there is a character (0x9d) that is not found. I wonder if there is a way to impose an encoding that would work, say
open(DATA_PATH, "rt",encoding = "utf-8")

albop commented
Mv77 commented

Updating to 0.15 did fix the issue, thanks @albop.

For some reason pip install dolo is installing dolang==0.0.14 for me. Did not know .15 was out. Thanks again!