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 martin.panter
Recipients martin.panter, socketpair
Date 2016-02-10.01:52:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455069126.04.0.680249372248.issue26318@psf.upfronthosting.co.za>
In-reply-to
Content
I agree that the business with “name” is a mess. I don’t know what the best solution is. FileIO.name is already documented as being a file descriptor in some cases.

Perhaps we should document that the Buffered and Text wrappers inherit the wrapped name, but if the underlying object has no “name” attribute then neither does the wrapper object. E.g.: TextIOWrapper(BufferedReader(BytesIO())).name. Also document that a string name is more a rough description and may not be technically accurate, e.g. sys.stdin.buffer.raw.name is always "<stdin>".

I’m not sure that changing the name to None would be much of an improvement over having it an integer file descriptor. It would probably hurt debugging and error messages. IMO it is the APIs like tarfile that are broken when they assume “name” is a technically valid file name string.

In the tarfile module, there are two uses a file’s “name” attribute that I know of:

TarFile constructor: Since the main change for Issue 21044 was made, the TarFile constructor only uses the underlying name attribute if it is str or bytes.

TarFile.gettarinfo(): See Issue 21996 and my. I proposed some documentation in Issue 22468 to clarify the behaviour. In one use case, I had to override the “name” attribute with a dummy “arcname” argument, and then set the real name later on.
History
Date User Action Args
2016-02-10 01:52:06martin.pantersetrecipients: + martin.panter, socketpair
2016-02-10 01:52:06martin.pantersetmessageid: <1455069126.04.0.680249372248.issue26318@psf.upfronthosting.co.za>
2016-02-10 01:52:05martin.panterlinkissue26318 messages
2016-02-10 01:52:03martin.pantercreate