python-minifier icon indicating copy to clipboard operation
python-minifier copied to clipboard

UnicodeEncodeError?

Open FrancHR opened this issue 2 years ago • 1 comments

Last few days i have UnicodeEncodeError. Never had this before until now. There is no matter which code i have in py files. I also tried files which has successfully minified in the past, but now they have UnicodeEncodeError. I had version 2.6.0, and today i have updated to 2.8.0 and i have the same error.

Python version 3.9 on Windows 11.

C:\Users\Zet>pyminify C:\Users\Zet\Desktop\work\wrapper.py --in-place

C:\Users\Zet\Desktop\work\wrapper.py
Traceback (most recent call last):
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python39\Scripts\pyminify.exe\__main__.py", line 7, in <module>
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python39\lib\site-packages\python_minifier\__main__.py", line 64, in main
    f.write(minified)
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1988-1994: character maps to <undefined>

Also, tried in python 3.11:

C:\Users\Zet>pyminify C:\Users\Zet\Desktop\work\main.py --in-place

C:\Users\Zet\Desktop\work\main.py
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\Zet\AppData\Local\Programs\Python\Python311\Scripts\pyminify.exe\__main__.py", line 7, in <module>
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python311\Lib\site-packages\python_minifier\__main__.py", line 64, in main
    f.write(minified)
  File "C:\Users\Zet\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 28221-28227: character maps to <undefined>

On Ubuntu 20.04 and pyminfy v.2.8.0, with the same files everything is ok.

FrancHR avatar Jan 28 '23 18:01 FrancHR

This sounds related to #57

dflook avatar Jan 28 '23 20:01 dflook