This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IOError has no __unicode__ method - and loses information
Type: Stage:
Components: IO Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: unicode(exception) and str(exception) should return the same message on Py2.6
View: 6108
Assigned To: Nosy List: benjamin.peterson, georg.brandl, michael.foord
Priority: normal Keywords: 26backport

Created on 2009-09-11 20:50 by michael.foord, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg92525 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-09-11 20:50
>>> try:
...  open('flooble')
... except Exception as e:
...  pass
... 
[39343 refs]
>>> str(e)
"[Errno 2] No such file or directory: 'flooble'"
[39345 refs]
>>> unicode(e)
u"(2, 'No such file or directory')"

The Unicode representation of an IOError has no information about the
file or directory name. This is a regression from 2.5. Would be nice to
backport a fix to 2.6 if we can.

This bit docutils - and can happen as a side-effect of interpolating
into a Unicode string with %s. The filename information is lost from the
error report.
msg92528 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-09-11 22:06
If your curious, this is the bug report that broke it:
http://bugs.python.org/issue2517
msg92713 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-16 19:59
And this is a duplicate of (the somewhat complicated-named) #6108.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51139
2009-09-16 19:59:17georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg92713

superseder: unicode(exception) and str(exception) should return the same message on Py2.6
resolution: duplicate
2009-09-11 22:06:32benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg92528
2009-09-11 20:50:43michael.foordcreate