dwgoon / jpegio

A python package for accessing the internal variables of JPEG file format such as DCT coefficients and quantization tables
Apache License 2.0
73 stars 18 forks source link

Unknown error with non-english path #19

Open Vadim2S opened 2 years ago

Vadim2S commented 2 years ago

Tested. English-only path to .jpeg work OK, National encoding lead to error.

dwgoon commented 2 years ago

Could you please show me your code snippet that contains a non-english path?

Vadim2S commented 2 years ago

I am do some test and found another prerequisite for error: Windows Case 1: Pure Linux or WSL: jpeg = jpegio.read("/mnt/c/!4/bbb/example.jpg") #english only jpeg = jpegio.read("/mnt/c/!4/ббб/example.jpg") #not only english All Ok Case 2: Windows: jpeg = jpegio.read("c:\!4\bbb\example.jpg") #english only jpeg = jpegio.read("c:\!4\ббб\example.jpg") #not only english jpeg = jpegio.read("c:/!4/ббб/example.jpg") #not only english, reverse slash OK, error, error: jpeg = jpegio.read("c:/!4/ббб/example.jpg") File "C:\Users\Вадим\AppData\Roaming\Python\Python39\site-packages\jpegio\io.py", line 8, in read obj.read(fpath) File "jpegio\decompressedjpeg.pyx", line 38, in jpegio.decompressedjpeg.DecompressedJpeg.read File "jpegio\decompressedjpeg.pyx", line 46, in jpegio.decompressedjpeg.DecompressedJpeg.read RuntimeError: Unknown exception

xfeep commented 1 year ago

It uses fpath.encode() which uses utf8 by default. So if we use non-english path on non-utf8 system, e.g. Windows, it will fail.