pystardict
pystardict copied to clipboard
Attribute 'message' does not exist in IOErrors in Python 3.5
I encountered such an exception. It said it cannot find a *.dict
file while actually a *.dict.dz
is there.
>>> d = Dictionary('DrEye-jc')
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/pystardict.py", line 647, in open_file
return open(regular, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'DrEye-jc.dict'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/pystardict.py", line 371, in __init__
self._file = open_file(dict_filename, dict_filename_dz)
File "/usr/lib/python3.5/site-packages/pystardict.py", line 649, in open_file
warn(e.message)
AttributeError: 'FileNotFoundError' object has no attribute 'message'
I then read the code and found it may be the problem of open_file
function, where statements like warn(e.message)
exists. Some tests I did indicated that expressions like IOError("abc").message
work in Python 2.x but 3.x. So there may need some conditional tests before warnings to ensure the compatibility.
Thank you for your great work and hope for a fix.
@Shihira thanks for the report! I'll dig into it on the weekend.
PR will be welcomed