This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: FileIO object in io module
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, barry, beazley, benjamin.peterson, christian.heimes
Priority: release blocker Keywords: needs review, patch

Created on 2008-11-20 13:18 by beazley, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fileio_attributes.patch amaury.forgeotdarc, 2008-11-20 15:31
socketio_attributes.patch amaury.forgeotdarc, 2008-11-20 23:05
fileio_always_binary.patch benjamin.peterson, 2008-11-20 23:53
Messages (9)
msg76100 - (view) Author: David M. Beazley (beazley) Date: 2008-11-20 13:18
The FileIO object defined in the new io library has "name" and "mode" 
properties.  However, attempts to access either value result in an 
AttributeError exception.   The C source code in _fileio.c doesn't even 
implement a name attribute and it uses a different name for mode ("mode" 
instead of "_mode" that the property is looking for).

Broken in 2.6 and 3.0rc2.
msg76102 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-11-20 13:32
This needs to be verified before the next rc gets out.
msg76109 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-20 15:31
The attached patch is an attempt to set mode and name attributes to all
three objects in the IO stack.
For example, 
>>> f = open("foo", "U+")
>>> f.buffer.name, f.buffer.mode
('foo', 'r+')

See also the unit tests.


There is a little inconsistency that I don't know how to resolve: with
my patch, the mode does not round-trip: open(name, mode).mode is not
always equal to mode:
>>> f = open("foo", "rb")
>>> f.name, f.mode
('t', 'r')
The 'b' was removed because f is already a binary file returning bytes.

But it seems better than attaching the initial mode to the FileIO
object. Currently,
>>> io.open("foo", "Ub+", buffering=0)
_fileio._FileIO(3, 'r+')
>>> io.open("foo", "Ub+", buffering=0).mode
'Ub+'
Which is even more surprising IMO.
msg76134 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2008-11-20 20:07
I'm okay with the roundtrip not being supported.  One thing I don't
quite understand is in the third test, where you're using "w+" mode and
testing f.buffer.mode and f.buffer.raw.mode is "r+".  Why is that?
msg76136 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2008-11-20 20:16
r67300 (with after the fact whitespace normalization of
Lib/tests/test_io.py)
msg76146 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-20 22:48
Reopening, since this causes failure in socket.makefile()
msg76148 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-20 23:05
This patch addresses the makefile() function and the SocketIO class.
msg76152 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-11-20 23:53
Here's a patch that makes FileIO accept and return 'b' in its mode string.
msg76154 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-11-21 00:13
Since, we don't really care about round-tripping, test_gzip was fixed in
r67309.
History
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48612
2008-11-21 00:13:05benjamin.petersonsetstatus: open -> closed
messages: + msg76154
2008-11-20 23:53:46benjamin.petersonsetfiles: + fileio_always_binary.patch
nosy: + benjamin.peterson
messages: + msg76152
2008-11-20 23:42:07barrysetstatus: closed -> open
2008-11-20 23:37:34barrysetstatus: open -> closed
resolution: fixed
2008-11-20 23:05:29amaury.forgeotdarcsetfiles: + socketio_attributes.patch
messages: + msg76148
2008-11-20 22:48:21amaury.forgeotdarcsetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg76146
2008-11-20 22:02:19amaury.forgeotdarcsetresolution: fixed
2008-11-20 20:16:30barrysetstatus: open -> closed
messages: + msg76136
2008-11-20 20:07:28barrysetnosy: + barry
messages: + msg76134
2008-11-20 15:31:07amaury.forgeotdarcsetkeywords: + needs review, patch
files: + fileio_attributes.patch
messages: + msg76109
nosy: + amaury.forgeotdarc
2008-11-20 13:32:34christian.heimessetpriority: release blocker
nosy: + christian.heimes
stage: test needed
messages: + msg76102
versions: + Python 3.0
2008-11-20 13:18:27beazleycreate