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.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, beazley, christian.heimes
Date 2008-11-20.15:31:05
SpamBayes Score 7.89146e-11
Marked as misclassified No
Message-id <1227195067.75.0.992780074304.issue4362@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-11-20 15:31:07amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, beazley, christian.heimes
2008-11-20 15:31:07amaury.forgeotdarcsetmessageid: <1227195067.75.0.992780074304.issue4362@psf.upfronthosting.co.za>
2008-11-20 15:31:07amaury.forgeotdarclinkissue4362 messages
2008-11-20 15:31:06amaury.forgeotdarccreate