[issue18534] State clearly that open() 'file' param is "name" attr of the result

2017-10-31 Thread Guido van Rossum

Guido van Rossum  added the comment:

Agreed it's too subtle to change the behavior.

> We may also want to explicitly point out that using os.fsdecode(name) before 
> passing it to open() will ensure that the name attribute is set to a string 
> rather than a bytes object.

Not sure. Are there cases where os.fsdecode() fails even if the binary syscall 
would succeed? (The docs claim that on Windows it uses 'strict'.)

If it doesn't, maybe we can add a new attribute that gives the name as Text? It 
could be '' if name is an int.

--
nosy: +gvanrossum
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18534] State clearly that open() 'file' param is "name" attr of the result

2017-10-28 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18534] State clearly that open() 'file' param is "name" attr of the result

2013-07-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Switching this to a docs bugs, since 
http://docs.python.org/3/library/functions.html#open doesn't mention this 
behaviour at all, and http://docs.python.org/3/library/io.html#io.FileIO.name 
only notes the fact it may be a file descriptor without mentioning the 
str/bytes discrepancy.

So, at a bare minimum, we need to clearly describe this behaviour in the docs. 
We may also want to explicitly point out that using os.fsdecode(name) before 
passing it to open() will ensure that the name attribute is set to a string 
rather than a bytes object.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: File "name" attribute should always be a text string -> State clearly 
that open() 'file' param is "name" attr of the result
versions: +Python 3.3, Python 3.4

___
Python tracker 

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