Message76225
The changes following r67300 introduced the .mode and .name attributes on all
the file-like objects returned by the open() function.
This also changed the mode returned by a file opened in binary mode: it was
"rb", now it is "r". The fact that the mode does not "round-trip" (i.e: open(f,
mode).mode != mode) was considered not important.
But now it is difficult to see if some opened file was opened in text or binary
mode; in test_gzip.py, a test had to be changed, and now it does not test
anything at all: the intent of the test is just to verify that a zip file is
always opened in binary mode.
Benjamin suggested to change the mode returned by FileIO objects, so that they
always contain a 'b'. They also accept an extra 'b' on creation: it is just
ignored.
Now, for a file opened in text mode:
>>> f = open('filename')
>>> assert f.mode == 'r'
>>> assert f.buffer.mode == 'rb'
>>> assert f.buffer.raw.mode == 'rb'
The mode attribute is now always consistent with the one passed to the open()
function. This also avoid gratuitous breakage with python2.x.
Patch attached. All tests pass. |
|
Date |
User |
Action |
Args |
2008-11-22 00:13:20 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, benjamin.peterson |
2008-11-22 00:13:19 | amaury.forgeotdarc | set | messageid: <1227312799.3.0.532336276837.issue4386@psf.upfronthosting.co.za> |
2008-11-22 00:13:18 | amaury.forgeotdarc | link | issue4386 messages |
2008-11-22 00:13:17 | amaury.forgeotdarc | create | |
|