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 vstinner
Recipients vstinner
Date 2008-12-28.16:57:08
SpamBayes Score 4.51508e-05
Marked as misclassified No
Message-id <1230483429.96.0.00901303311895.issue4762@psf.upfronthosting.co.za>
In-reply-to
Content
PyFile_FromFd() never changes the name of new created file object:

$ ./python -c "import sys; print(sys.stdout.buffer.name, 
sys.stdout.name)"
0 0

Expected result: <stdout> <stdout>.

---

Binary mode:
 - with buffering == 0, the file object is a FileIO. Changing the name 
can be done with: file._name=new_name
 - with buffering != 0, the file object is a BufferedXXX() and 
file.raw is a FileIO. So we have to set: file.raw._name=new_name

If text mode, the file object is a TextIOWrapper and file.raw is a 
BufferedXXX() (buffering=0 is forbidden for text file). So changing 
the name can be done with: file.raw.raw._name=newname.

I'm not sure of the classes/types.

Note: PyFile_FromFd() shouldn't use PyErr_Clear() if changing the name 
fails.
History
Date User Action Args
2008-12-28 16:57:10vstinnersetrecipients: + vstinner
2008-12-28 16:57:09vstinnersetmessageid: <1230483429.96.0.00901303311895.issue4762@psf.upfronthosting.co.za>
2008-12-28 16:57:09vstinnerlinkissue4762 messages
2008-12-28 16:57:09vstinnercreate