[issue14161] python2 file __repr__ does not escape filename

Ezio Melotti report at bugs.python.org
Thu Mar 1 09:01:18 CET 2012


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

The attached patch seems to do the trick (not sure if it's the best way to fix the issue though):
>>> open('woo\raa')
<open file 'woo\raa', mode 'r' at 0xb77c2aa8>
>>> open('woo\ra\'a', 'w')
<open file "woo\ra'a", mode 'w' at 0xb77c2b88>
>>> open('woo\ra\'a"', 'w')
<open file 'woo\ra\'a"', mode 'w' at 0xb77c2b18>
>>> 

It's more or less equivalent to:
- return "<open file '%s', mode '%s' at %p>" % (fname, mode, addr)
+ return "<open file %s, mode '%s' at %p>" % (repr(fname), mode, addr)

----------
keywords: +patch
stage: needs patch -> test needed
Added file: http://bugs.python.org/file24694/issue14161.diff

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


More information about the Python-bugs-list mailing list