Message78419
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. |
|
Date |
User |
Action |
Args |
2008-12-28 16:57:10 | vstinner | set | recipients:
+ vstinner |
2008-12-28 16:57:09 | vstinner | set | messageid: <1230483429.96.0.00901303311895.issue4762@psf.upfronthosting.co.za> |
2008-12-28 16:57:09 | vstinner | link | issue4762 messages |
2008-12-28 16:57:09 | vstinner | create | |
|