python-magic
python-magic copied to clipboard
encoding bug of windows 10, python3 with eyed3 0.8.5
I found it does work in python3, win10 with eyed3 0.8.5. it can not open a offending filename like '1호선 뮤직 - 열대야.mp3'. all that is because the code for open a file with encode('utf8') in magic.py. And i have fix that. you can check pull request.
- fix encoding bug of windows, maybe it is in only python3 sometimes
- add libmagic-1.dll supportting for https://github.com/nscaife/file-windows.git
Can you give more details of how to reproduce this?
I can reproduce it as below with:
python: 3.10 python-magic: 0.4.27 python-magic-bin: 0.4.14 OS: Windows 10
C:\Users\yyamano\work\poc>dir *.xlsm
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は A864-D280 です
C:\Users\yyamano\work\poc のディレクトリ
2023/03/24 10:00 102,100,573 20230310_01.xlsm
2023/03/24 10:00 102,100,573 日本語.xlsm
2 個のファイル 204,201,146 バイト
0 個のディレクトリ 350,047,604,736 バイトの空き領域
C:\Users\yyamano\work\poc>poetry run python poc-magic.py 20230310_01.xlsm 日本語.xlsm
File: 20230310_01.xlsm
Microsoft Excel 2007+
File: 日本語.xlsm
cannot open `\346\227\245\346\234\254\350\252\236.xlsm' (Illegal byte sequence)
C:\Users\yyamano\work\poc>type poc-magic.py
import magic
import sys
if __name__ == "__main__":
for file in sys.argv[1:]:
print(f"File: {file}")
print("\t" + magic.magic.from_file(file))
Merging into https://github.com/ahupp/python-magic/issues/287