[issue14161] python2 file __repr__ does not escape filename

Éric Araujo report at bugs.python.org
Thu Mar 1 06:58:17 CET 2012


Éric Araujo <merwok at netwok.org> added the comment:

Duh, obviously that code branch is used only for unicode paths:

  >>> open('/tmp/t\nest', 'w')
  <open file '/tmp/t
  est', mode 'w' at 0x7f6f0f3dd9c0>
  >>> open(u'/tmp/t\nest', 'w')
  <open file u'/tmp/t\nest', mode 'w' at 0x7f6f0f3dda50>

There does not seem to be something similar in http://docs.python.org/c-api/string, so I guess one would have to create intermediary objects to decode str to unicode, transform with unicode-escape and convert back to str.

----------

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


More information about the Python-bugs-list mailing list