You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2009-03-25.00:06:58.567>created_at=<Date2008-12-28.16:57:09.393>labels= ['type-bug']
title="PyFile_FromFd() doesn't set the file name"updated_at=<Date2010-08-13.13:36:35.408>user='https://github.com/vstinner'
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.
The last problem occurs with imp.find_module(). But imp.find_module()
also returns a "filename" argument, so I don't think that the issue
really matters. Let's close it ;-)
Activity
vstinner commentedon Dec 28, 2008
PyFile_FromFd() never changes the name of new created file object:
Expected result: <stdout> <stdout>.
---
Binary mode:
can be done with: file._name=new_name
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.
vstinner commentedon Dec 28, 2008
In my last patch to fix the issue bpo-4705, I replaced PyFile_FromFd() by
custom code which set correctly the file name.
PyFile_FromFd() is also used in:
PyFile_GetLine(file)
the wrong name
Example with imp:
vstinner commentedon Dec 28, 2008
The standard I/O: sys.stdin, sys.stdout and sys.stderr.
vstinner commentedon Mar 25, 2009
In py3k, standard streams' names are now correct (since the io-c
merge):
Python 3.1a1+ (py3k:70589M, Mar 25 2009, 01:01:13) >>> import sys >>> sys.stdin.name, sys.stdout.name, sys.stderr.name ('<stdin>', '<stdout>', '<stderr>')The last problem occurs with imp.find_module(). But imp.find_module()
also returns a "filename" argument, so I don't think that the issue
really matters. Let's close it ;-)
vstinner commentedon Aug 13, 2010
r83973 ignores the name argument of PyFile_FromFd() because it was already ignored (it did always produce an error).