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 The patch is attached. If you think it's ok to fix this I'll post it to the bug tracker -- Lawrence http://www.oluyede.org/blog -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: bz2module.diff.txt Url: http://mail.python.org/pipermail/python-dev/attachments/20060806/bd63dc42/attachment.txt
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