Another Windows zipfile encoding problem, with patch
Vepxistqaosani
vepxistqaosani at netscape.net
Sun May 4 15:18:05 EDT 2003
While cataloging the contents of all the zip files on my disk, I came
across a RuntimeError.
I had zipped up the /Windows directory, which included the file
/Windows/SendTo/3½ Floppy (A).lnk
zipfile.py then reports:
File name in directory "SendTo/3½ Floppy (A).lnk" and header
"SendTo/3+ Floppy (A).lnk" differ.
Something funny apparently happens to high-bit ascii characters.
I patched lines 284-7 (the end of the def of _RealGetContents) from
if fname != data.filename:
raise RuntimeError, \
'File name in directory "%s" and header "%s" differ.' % (
data.filename, fname)
to
if fname != data.filename:
if len(fname) != len(data.filename):
raise RuntimeError, \
'File name in directory "%s" and header "%s" differ.' % (
data.filename, fname)
which solved my present problem.
Ideally, I suppose, there would be a more robust solution involving an
encoding. Any suggestions?
Fred Bartlett
More information about the Python-list
mailing list