Python ZipFile Error problem

Source: Internet
Author: User
Tags unpack

Recently read the ZIP compression package in Python. To report a mistake.

Python 2.6.6 (r266:84292, June, 14:18:47) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on Linux2type "help", "copyright", "Credits" or "license" for more information.>>> import zipfile>>> ZipFile. ZipFile (' bla.apk ') Traceback (most recent call last):  file "<stdin>", line 1, in <module>  file "/usr/ lib64/python2.6/zipfile.py ", line 696, in __init__    self._getcontents ()  File"/usr/lib64/python2.6/ zipfile.py ", line 716, in _getcontents    self._realgetcontents ()  File"/usr/lib64/python2.6/zipfile.py ", line 772, in _realgetcontents    X._decodeextra ()  File '/usr/lib64/python2.6/zipfile.py ', line 351, in _decodeextra    TP, ln = unpack (' 

This should be considered a Python bug, detailed in the http://bugs.python.org/issue14315 here is discussed.

There are two solutions.

One is: According to this page discussed, hit a patch. Http://bugs.python.org/file24902/fix_zipfile_extra.patch.

Specifically, enter/usr/lib64/python2.6/zipfile.py this file, near line 351, the while extra: change to while Len (extra) >= 4:


Method Two is to upgrade the Python version.

The problem was found on the Python 2.6.6. This python is a Linux-brought version that may be lower. Upgrading 2.7.3 above, this issue has been resolved in the high version. So it's also a way to upgrade python.



Python ZipFile Error problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.