[Patches] [ python-Patches-403871 ] self.fp not defined in class ZipFile for non-existing file

nobody nobody@sourceforge.net
Tue, 27 Feb 2001 21:35:44 -0800


Patches #403871, was updated on 2001-02-18 20:01
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=403871&group_id=5470

Category: None
Group: None
Status: Closed
Priority: 5
Submitted By: Dave Kuhlman
Assigned to: Fred L. Drake, Jr.
Summary: self.fp not defined in class ZipFile for non-existing file

Initial Comment:
Here is a small nit, but perhaps a nit that needs to be picked.

I'm using Python 2.1a2 that I built from source on Win 2000 with VC++ 6.0.

In using the ZipFile module, I tried to trap the exception generated when the file does not exist.  I was surprised by the attribute exception, as shown below:

=====================================

//c/Dave/Python/Test [13] python
Python 2.1a2 (#10, Feb 13 2001, 10:45:16) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import zipfile as z
>>> try:
...     a = z.ZipFile('anonexistentfile.zip')
... except IOError:
...     print 'io error'
...
io error
Exception exceptions.AttributeError: "ZipFile instance has no attribute 'fp'" in
 <method ZipFile.__del__ of ZipFile instance at 008796D4> ignored
>>>

=====================================

I fixed this by adding the following line at the beginning of method __init__() in class ZipFile in file lib/zipfile.py:

        self.fp = None

Hope this helps.

  - Dave


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

Comment By: Fred L. Drake, Jr.
Date: 2001-02-27 21:35

Message:
Logged In: YES 
user_id=3066

Fixed in Lib/zipfile.py revision 1.6; regression test added
in Lib/test/test_zipfile.py revision 1.3.

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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=403871&group_id=5470