[Patches] [ python-Patches-1535500 ] writelines() in bz2 module does not raise check for errors
SourceForge.net
noreply at sourceforge.net
Sun Aug 6 21:32:29 CEST 2006
Patches item #1535500, was opened at 2006-08-06 21:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1535500&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: Modules
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Lawrence Oluyede (rhymes)
Assigned to: Nobody/Anonymous (nobody)
Summary: writelines() in bz2 module does not raise check for errors
Initial Comment:
In the BZ2File object of bz2 module the writelines()
method does not
check its closed state before doing the actual work so
its behavior
it's different from write()'s behavior. See:
>>> from bz2 import BZ2File
>>> f = BZ2File("foo", "w")
>>> f.close()
>>> f.closed
1
>>> f.write("foobar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> f.closed
1
>>> f.writelines(["foobar"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: unknown IO error
It also doesn't check if it can write for real:
>>> from bz2 import BZ2File
>>> f = BZ2File("foo", "r")
>>> f.write("foobar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: file is not ready for writing
>>> f.writelines(['foobar'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: wrong sequence of bz2 library commands used
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1535500&group_id=5470
More information about the Patches
mailing list