[issue4927] Inconsistent unicode repr for fileobject

Kristján Valur Jónsson report at bugs.python.org
Thu Jan 15 18:35:09 CET 2009


Kristján Valur Jónsson <kristjan at ccpgames.com> added the comment:

Just to clarify, 
Ascii files and unicode files will repr() as
<open file 'tmp\foo', mode 'wb' at ...>
<open file u'tmp\\foo', mode 'wb' at ...>
respectively.  In the former, the backslash isn't escaped, but in the 
latter it is.  The single quotes certainly imply repr, and if this were 
a list, it would repr as:
['tmp\\foo']
and so I think that the ascii syntax really ought to be
<open file 'tmp\\foo', mode 'wb' at ...>


The inconsistency shows up in the testsuite for test_file() when the 
TMPFN is tmp\@test (because test_support didn't succeed in creating a 
temp file @test) when it is checking the repr of a file opened with a 
unicode filename with code that corresponds exactly to code used for an 
string filename.

Any thoughts?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4927>
_______________________________________


More information about the Python-bugs-list mailing list