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 nadeem.vawda
Recipients gregory.p.smith, jld, nadeem.vawda
Date 2012-01-16.22:37:57
SpamBayes Score 2.0168311e-12
Marked as misclassified No
Message-id <>
For 3.x, I think that ignoring non-string names is a reasonable fix. The docs
for io.FileIO specify that its name attribute can be either a path or an integer
file descriptor, and changing this doesn't seem to serve any purpose.

As for the case of 2.7's bogus "<fdopen>" name attribute, I'm not sure what the
best course of action is. I agree that ideally we would want to get rid of the
attribute altogether (for objects returned by fdopen), or change the semantics
to those used by FileIO in 3.x, but making that sort of change in a bugfix
release seems unwise.

One alternative would be for GzipFile to specifically check whether a file
object was returned by fdopen(), and if so ignore the fake name. I'm not sure
how this could be accomplished, though - just checking for name == "<fdopen>" is
too fragile for my liking, and I can't see any other obvious way of
distinguishing objects created by fdopen() from those created by open().

> (another quick test shows that gzip in python 3.x can't output to a BytesIO
> fileobj at all, it thinks it is readonly)

Are you sure about this? I can't reproduce the problem. Running this script:

    import gzip, io

    b = io.BytesIO()
    with gzip.GzipFile(fileobj=b, mode="w") as g:
        g.write(b"asdf ghjk")
    with gzip.GzipFile(fileobj=b, mode="r") as g:

I get the following output:

    b'asdf ghjk'
Date User Action Args
2012-01-16 22:37:58nadeem.vawdasetrecipients: + nadeem.vawda, gregory.p.smith, jld
2012-01-16 22:37:58nadeem.vawdasetmessageid: <>
2012-01-16 22:37:57nadeem.vawdalinkissue13781 messages
2012-01-16 22:37:57nadeem.vawdacreate