OCA / odoo-pre-commit-hooks

Linters of Odoo addons that complement pylint-odoo
GNU Affero General Public License v3.0
10 stars 12 forks source link

po_pretty_format crash because of unknown character on charmap #95

Open d3Ex22 opened 7 months ago

d3Ex22 commented 7 months ago

I have this error as soon as po_pretty_format tries to auto fix an issue.

File "C:\Users\abgra\.cache\pre-commit\repobx9s45r5\py_env-python3.12\Lib\site-packages\oca_pre_commit_hooks\checks_odoo_module_po.py", line 82, in perform_autofix
    print(f"Fixing {self.filename_short} \u2692")
  File "C:\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 '\u2692' in position 32: character maps to <undefined>

removing the \u2692 in the line resolve the problem. (this character is the "hammer and pick" and i really dont understand why it's here)

moylop260 commented 7 months ago

Hi @d3Ex22

Thank you for reporting this issue

I'm trying to reproduce it locally but I'm not able to do it

Locally I'm using MacOSX, I have installed the same python3.12 version as you

The difference is that you are using windows

I don't have a windows computer to reproduce it

So, I'm using the github actions with windows in our CI to reproduced

But using py3.11 with windows the issue is not reproduced

Notice the following line:

It is working well in a similar environment as you

It is hard to fix it for me if I don't have an environment to reproduce it

But you have reproduced locally so maybe it could be easy for you fix it testing using a encode in the python code or using locales configuration in the OS

Or something else

Also, I'm not sure if removing the special char it fixes the error since that in other places we are using colors and so on

Could you help us, please?

d3Ex22 commented 7 months ago

Hi @moylop260 and thanks for your quick answer. May the problem come from Vscode Powershell terminal ? Or a encoding problem (utf-8 in my case, i think).

For me removing locally the symbol resolved the issue and also colors are working well as you can see here:

image

Haven't met any other bugs since.