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

[BUG] -f option uses wrong encoding (cp1252) on Windows for UTF-8 files #130

Open
sanzoghenzo opened this issue Feb 23, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@sanzoghenzo
Copy link
Contributor

sanzoghenzo commented Feb 23, 2023

Describe the bug

Using jake ddt -f poetry.lock -t POETRY on a windows machine (still on python 3.7 unfortunately) can result in UnicodeDecodeErrors.

In my case the error is thrown because of a unicode character in the description of the mergedeep package.

  File "jake\app.py", line 122, in main
    JakeCmd(args).execute()
  File "ake\app.py", line 96, in execute
    exit_code: int = command.execute(arguments=self._arguments)
  File "jake\command\__init__.py", line 43, in execute
    return self.handle_args()
  File "jake\command\oss.py", line 83, in handle_args
    self.arguments.sbom_input_type, self.arguments.sbom_input_source
  File "jake\command\parser_selector.py", line 26, in get_parser
    input_data = input_data_fh.read()
  File "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 78405: character maps to <undefined>

To Reproduce
Steps to reproduce the behavior:

poetry new jake-test
cd jake-test
poetry add mergedeep
jake ddt -f poetry.lock -t POETRY

Expected behavior
poetry.lock should be parsed correctly.

Desktop (please complete the following information):

  • OS: Windows 10
  • Python Version: 3.7.9
  • Version 3.0.0

Additional context
This can be solved adding , encoding="utf-8" to the FileType constructor of the -f parameter.

I don't know if this will generate any unwanted side effects; python 2.7 times are gone, but I could be missing something.

@sanzoghenzo sanzoghenzo added the bug Something isn't working label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant