[issue4762] PyFile_FromFd() doesn't set the file name

2009-03-24 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

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 ;-)

--
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4762
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4762] PyFile_FromFd() doesn't set the file name

2008-12-28 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

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.

--
components: None
messages: 78419
nosy: haypo
severity: normal
status: open
title: PyFile_FromFd() doesn't set the file name
type: behavior
versions: Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4762
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4762] PyFile_FromFd() doesn't set the file name

2008-12-28 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

In my last patch to fix the issue #4705, I replaced PyFile_FromFd() by 
custom code which set correctly the file name.

PyFile_FromFd() is also used in:
 - _Py_DisplaySourceLine(): name is not used, only 
PyFile_GetLine(file)
 - call_find_module() (imp.find_module()): return the file object with 
the wrong name

Example with imp:

 file, filename, extra = imp.find_module(os)
 file
io.TextIOWrapper object at 0xb7b6ea6c
 file.name
4
 filename
'/home/SHARE/SVN/py3k/Lib/os.py'

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4762
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4762] PyFile_FromFd() doesn't set the file name

2008-12-28 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 In my last patch to fix the issue #4705, I replaced PyFile_FromFd()
 by custom code which set correctly the file name.

The standard I/O: sys.stdin, sys.stdout and sys.stderr.

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4762
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4762] PyFile_FromFd() doesn't set the file name

2008-12-28 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4762
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com