mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Bug #1194181: bz2.BZ2File didn't handle mode 'U' correctly.
This commit is contained in:
parent
6d6917be00
commit
6b95f1d963
3 changed files with 16 additions and 0 deletions
|
|
@ -235,6 +235,16 @@ class BZ2FileTest(BaseTest):
|
||||||
# "Test opening a nonexistent file"
|
# "Test opening a nonexistent file"
|
||||||
self.assertRaises(IOError, BZ2File, "/non/existent")
|
self.assertRaises(IOError, BZ2File, "/non/existent")
|
||||||
|
|
||||||
|
def testModeU(self):
|
||||||
|
# Bug #1194181: bz2.BZ2File opened for write with mode "U"
|
||||||
|
self.createTempFile()
|
||||||
|
bz2f = BZ2File(self.filename, "U")
|
||||||
|
bz2f.close()
|
||||||
|
f = file(self.filename)
|
||||||
|
f.seek(0, 2)
|
||||||
|
self.assertEqual(f.tell(), len(self.DATA))
|
||||||
|
f.close()
|
||||||
|
|
||||||
class BZ2CompressorTest(BaseTest):
|
class BZ2CompressorTest(BaseTest):
|
||||||
def testCompress(self):
|
def testCompress(self):
|
||||||
# "Test BZ2Compressor.compress()/flush()"
|
# "Test BZ2Compressor.compress()/flush()"
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,8 @@ Core and builtins
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Bug #1194181: bz2.BZ2File didn't handle mode 'U' correctly.
|
||||||
|
|
||||||
- Patch #1212117: os.stat().st_flags is now accessible as a attribute
|
- Patch #1212117: os.stat().st_flags is now accessible as a attribute
|
||||||
if available on the platform.
|
if available on the platform.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1308,6 +1308,10 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode_char == 0) {
|
||||||
|
mode_char = 'r';
|
||||||
|
}
|
||||||
|
|
||||||
mode = (mode_char == 'r') ? "rb" : "wb";
|
mode = (mode_char == 'r') ? "rb" : "wb";
|
||||||
|
|
||||||
self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)",
|
self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue