You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/benjaminp'closed_at=<Date2008-11-22.00:42:13.333>created_at=<Date2008-11-22.00:13:18.187>labels= ['type-bug', 'release-blocker']
title='A binary file should show "b" in its mode'updated_at=<Date2008-11-22.00:42:13.332>user='https://github.com/amauryfa'
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.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: