[New-bugs-announce] [issue4927] Inconsistent unicode repr for fileobject

Kristján Valur Jónsson report at bugs.python.org
Tue Jan 13 10:21:37 CET 2009

New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:

The repr for fileobjects is inconsistent.  On windows:
f = file("tmp\\foo", "wb")
<open file 'tmp\foo', mode 'wb' at ...>
f = file(u"tmp\\foo", "wb")
<open file u'tmp\\foo', mode 'wb' at ...>

For unicode, the filename is a proper "repr", but for a string it is 
just the plain string, enclosed in single quotes.  Note that I consider 
the string case in error.  Like the repr of a list or tuple, it should 
be a string containin the repr of its components.

This leads to problems in the testsuite on vista.

I propose to change this with the patch provided, which always displays 
the repr of the filename.  It may have side effects in the testsuite, I 
will add a separate file for that.

components: Interpreter Core
files: fileobject.patch
keywords: needs review, patch, patch
messages: 79726
nosy: krisvale
severity: normal
stage: patch review
status: open
title: Inconsistent unicode repr for fileobject
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file12713/fileobject.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list