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

Error while committing due to a UnicodeEncodeError (RDT-756) #22

Closed
YosstinCode opened this issue Apr 2, 2024 · 2 comments
Closed

Error while committing due to a UnicodeEncodeError (RDT-756) #22

YosstinCode opened this issue Apr 2, 2024 · 2 comments
Assignees
Labels
Awaiting Response Awaiting a response from the author

Comments

@YosstinCode
Copy link

YosstinCode commented Apr 2, 2024

Description

When attempting to commit changes to the repository, the commit fails due to a UnicodeEncodeError. The error occurs specifically when the conventional-precommit-linter hook is executed. The hook attempts to print a Unicode character (\u274c), causing the encoding error.

Traceback

Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Fix requirements.txt.................................(no files to check)Skipped
black....................................................................Passed
Fix requirements.txt.................................(no files to check)Skipped
black................................................(no files to check)Skipped
Conventional Commit......................................................Failed
- hook id: conventional-precommit-linter
- exit code: 1

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Scripts\conventional-precommit-linter.EXE\__main__.py", line 7, in 
<module>
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Lib\site-packages\conventional_precommit_linter\hook.py", line 194, in main
    print(f'\u274c Missing colon after {_color_purple("<type>")} or {_color_blue("(<optional-scope>)")}.')
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Lib\site-packages\colorama\ansitowin32.py", line 47, in write      
    self.__convertor.write(text)
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Lib\site-packages\colorama\ansitowin32.py", line 177, in write     
    self.write_and_convert(text)
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Lib\site-packages\colorama\ansitowin32.py", line 202, in write_and_convert
    self.write_plain_text(text, cursor, start)
  File "C:\Users\Yosst\.cache\pre-commit\repor_xbn2az\py_env-python3.12\Lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
    self.wrapped.write(text[start:end])
  File "C:\Users\Yosst\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u274c' in position 0: character maps to <undefined>

Precommit-config

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: requirements-txt-fixer
-   repo: https://github.com/psf/black
    rev: 24.3.0
    hooks:
    -   id: black
- repo: https://github.com/espressif/conventional-precommit-linter
  rev: v1.3.0
  hooks:
    - id: conventional-precommit-linter
      stages: [commit-msg]

minimum_pre_commit_version: 3.3.0
default_install_hook_types: [pre-commit,commit-msg]
@github-actions github-actions bot changed the title Error while committing due to a UnicodeEncodeError Error while committing due to a UnicodeEncodeError (RDT-756) Apr 2, 2024
@tomassebestik tomassebestik self-assigned this Apr 5, 2024
@tomassebestik
Copy link
Member

Hi @YosstinCode, thank you for reporting this issue. Let me try to fix the problem.

  • Does this error appear with a specific commit message?
  • Does this error appear in newer versions as well (the latest release is v1.7.0; you are using v1.3.0)?

@tomassebestik tomassebestik added the Awaiting Response Awaiting a response from the author label Apr 5, 2024
@tomassebestik
Copy link
Member

tomassebestik commented Apr 7, 2024

Hi again, @YosstinCode,

I've ran a few tests and it appears the issue may be related to Unicode resolution (Windows).

Could you please test this version on your system, where complex Unicode characters have been replaced with simple text, and let me know if it resolves your problem?

repos:
  ...
  - repo: https://github.com/espressif/conventional-precommit-linter
    rev: v1.8.0-beta     # <------------   
    hooks:
      - id: conventional-precommit-linter
        stages: [commit-msg]

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response Awaiting a response from the author
Projects
None yet
Development

No branches or pull requests

2 participants