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

Crash on text file NOT containing us-ascii or utf-8 in first line #440

Open
clach04 opened this issue Dec 11, 2022 · 0 comments
Open

Crash on text file NOT containing us-ascii or utf-8 in first line #440

clach04 opened this issue Dec 11, 2022 · 0 comments

Comments

@clach04
Copy link
Contributor

clach04 commented Dec 11, 2022

Exception back trace:

python elodie.py import --destination=test_deleteme_out elodie/tests/files
/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.13) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
elodie/tests/files/invalid.jpg is not a valid media file. Skipping...
Traceback (most recent call last):
  File "elodie.py", line 378, in <module>
    main()
  File "/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/pyvenv_numpytest/lib/python3.8/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "elodie.py", line 140, in _import
    dest_path = import_file(current_file, destination, album_from_folder,
  File "elodie.py", line 67, in import_file
    dest_path = FILESYSTEM.process_file(_file, destination,
  File "/home/pi/code/py/elodie_clach04/elodie/filesystem.py", line 524, in process_file
    metadata = media.get_metadata()
  File "/home/pi/code/py/elodie_clach04/elodie/media/text.py", line 72, in get_metadata
    self.parse_metadata_line()
  File "/home/pi/code/py/elodie_clach04/elodie/media/text.py", line 149, in parse_metadata_line
    first_line = f.readline().strip()
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 54: invalid start byte

with the attached text file cp1252.txt NOTE this is artificially created but matches the characteristics of the real file that caused this.

As per #424 text file reading/writing is not documented but from the code this appears to be deliberate.

clach04 added a commit to clach04/elodie that referenced this issue Dec 11, 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

No branches or pull requests

1 participant