A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-bugs-list/2005-November/030896.html below:

[ python-Bugs-1170311 ] zipfile UnicodeDecodeError

[ python-Bugs-1170311 ] zipfile UnicodeDecodeErrorSourceForge.net noreply at sourceforge.net
Tue Nov 1 23:42:32 CET 2005
Bugs item #1170311, was opened at 2005-03-24 21:51
Message generated for change (Comment added) made by smigyull
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170311&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: adam davis (adamx97)
Assigned to: Nobody/Anonymous (nobody)
Summary: zipfile UnicodeDecodeError

Initial Comment:
I think this is the same as #  705295, which may have
been prematurely closed.

I think the error is dependent on the data or time.

File "C:\Python24\lib\zipfile.py", line 166, in FileHeader
    return header + self.filename + self.extra
UnicodeDecodeError: 'ascii' codec can't decode byte
0xd0 in position 10: ordinal not in range(128)

The header is packed like this:
        header = struct.pack(structFileHeader,
stringFileHeader,
                 self.extract_version, self.reserved,
self.flag_bits,
                 self.compress_type, dostime, dosdate, CRC,
                 compress_size, file_size,
                 len(self.filename), len(self.extra))

the header is:

[Dbg]>>> header
'PK\x03\x04\x14\x00\x00\x00\x00\x00\xd0\xa9x2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x00'

and here are the parts that made it up:

[Dbg]>>> structFileHeader, stringFileHeader,
self.extract_version, self.reserved,
self.flag_bits,self.compress_type, dostime, dosdate,
CRC, compress_size, file_size, len(self.filename),
len(self.extra)
('<4s2B4HlLL2H', 'PK\x03\x04', 20, 0, 0, 0, 43472,
12920, 0, 0, 0, 45, 0)


here's the pieces of the 

----------------------------------------------------------------------

Comment By: Jean-Roch Roy (smigyull)
Date: 2005-11-01 17:42

Message:
Logged In: YES 
user_id=1371642

Python 2.4/WinXPSP2

I'm able to reproduce this bug. Create an arbitrary file named 
"Test.bin" having a time stamp of 2005-11-01 16:15:32. Then 
run this code:

import zipfile
zipFile = zipfile.ZipFile("Test.zip", "w", zipfile.ZIP_DEFLATED)
zipFile.write(u"Test.bin")

You should see the aforementionned traceback. The problem 
occurs when 1. pack() returns a string with some characters > 
128 (depends on time stamp); and 2. write() is called with a 
unicode parameter (instead of a str parameter).

----------------------------------------------------------------------

Comment By: adam davis (adamx97)
Date: 2005-03-30 22:51

Message:
Logged In: YES 
user_id=175166

The "here's the pieces of the" was an accident, you can
ignore it.

My filename was pure ascii, something like
"myemail at test.com.crt"

It seems to me the problem is that the header isn't
decodable.  0xd0 is  208, which is > 128.

----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2005-03-30 14:27

Message:
Logged In: YES 
user_id=38388

The problem is not the data in the file, but the fact that
your filename is probably a Unicode object which fails to
concatenate with the header (which clearly isn't ASCII :-).

I have no idea whether ZIP files support anything other than
ASCII filenames. If you have a reference, please let us know.

If your filename only contains ASCII characters, you should
be able to open the file correctly by first encoding the
filename to ASCII: filename.encode('ascii').
Perhaps zipfile.py should do that for you ?!


----------------------------------------------------------------------

Comment By: Terry J. Reedy (tjreedy)
Date: 2005-03-30 13:39

Message:
Logged In: YES 
user_id=593130

Your report ends with 'here's the pieces of the'.  Was something 
cut off?  If you meant to attach a file, try again.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170311&group_id=5470
More information about the Python-bugs-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4