[issue18534] File "name" attribute should always be a text string

2013-07-23 Thread Nick Coghlan
Nick Coghlan added the comment: Ouch, that complicates matters :( It also occurs to me that given the existence of the "opener" callback, name could be just about any type :P -- ___ Python tracker

[issue18534] File "name" attribute should always be a text string

2013-07-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Seconded Antoine. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue18534] File "name" attribute should always be a text string

2013-07-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: You can never assume that "name" will be a string: >>> f = open(0, "r") >>> f.name 0 This may be a bit of a bad idea API-wise, but changing it now will start breaking code, so I think we should leave it as-is. -- nosy: +aronacher, pitrou

[issue18534] File "name" attribute should always be a text string

2013-07-22 Thread Nick Coghlan
New submission from Nick Coghlan: Currently, if a byte sequence is passed to open() as the file name, the resulting file will have that object as its name: >>> open(os.path.expanduser(b"~/.hgrc")) <_io.TextIOWrapper name=b'/home/ncoghlan/.hgrc' mode='r' encoding='UTF-8'> >>> open(os.path.expand