Michael Foord mich...@voidspace.org.uk added the comment:
traceback patch looks good. Thanks for the unittest2 patch as well.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8313
___
Gregory P. Smith g...@krypto.org added the comment:
http://pypi.python.org/pypi/unittest2 says
There are several places in unittest2 (and unittest) that call str(...) on
exceptions to get the exception message. This can fail if the exception was
created with non-ascii unicode. This is rare
Gregory P. Smith g...@krypto.org added the comment:
We're on python 2.6, otherwise this would be a moot point. but you might want
to include something like that in a new unittest2 backport release.
--
___
Python tracker rep...@bugs.python.org
Michael Foord mich...@voidspace.org.uk added the comment:
Changing traceback._some_str to return unicode rather than str seems like a bad
idea.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8313
Changes by Michael Foord mich...@voidspace.org.uk:
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8313
___
___
Python-bugs-list mailing list
Michael Foord mich...@voidspace.org.uk added the comment:
I would prefer to try str(...) first and only attempt to convert to unicode and
do the backslash replace if the str(...) call fails.
--
___
Python tracker rep...@bugs.python.org
STINNER Victor victor.stin...@haypocalc.com added the comment:
Commited: r80777 (trunk) and r80779 (2.6); blocked: r80778 (py3k).
Open a new issue if you would like to use something better than
ASCII+backslashreplace in unittest (using runner stream encoding?).
--
resolution: - fixed
Gunnlaugur Thor Briem gunnlau...@gmail.com added the comment:
Replacing the message with its repr seems to me at least strongly preferable to
the current “hide it all” behavior. :)
Better, msg.encode('ascii', 'backslashreplace') does what repr does with
unencodable characters, but does not
Michael Foord mich...@voidspace.org.uk added the comment:
Sounds like a good solution - I'll look at this, thanks.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8313
___
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
Very recently, issue8533 changed regrtest.py to use 'backslashreplace' when
printing errors. This issue seems very similar
--
nosy: +amaury.forgeotdarc, haypo
___
Python tracker
STINNER Victor victor.stin...@haypocalc.com added the comment:
The example raises an AssertionError(u'\n- \ufffd+ \ufffd\ufffd') which is
converted to string by traceback.format_exception(). This function fails in
_some_str() on str(value) instruction. You can reproduce the error with:
STINNER Victor victor.stin...@haypocalc.com added the comment:
Very recently, issue8533 changed regrtest.py to use
'backslashreplace' when printing errors. This issue seems
very similar
Issue #8533 is not directly related because in this issue the error occurs
before writing the traceback
STINNER Victor victor.stin...@haypocalc.com added the comment:
Attached patch fixes _some_str() function of the traceback module: encode
unicode exception message to ASCII using backslashreplace error handler. ASCII
is not the best choice, but str(unicode(...)) uses also ASCII (the default
STINNER Victor victor.stin...@haypocalc.com added the comment:
The downside of using backslashreplace (or repr, for that matter) is
that it does not preserve lengths, so the diff markers can get
misaligned. I find that an acceptable tradeoff, but 'replace' is
another option that preserves
New submission from Michael Foord mich...@voidspace.org.uk:
import unittest
class Foo(unittest.TestCase):
... def test_fffd(self): self.assertEqual(u'\ufffd', u'\ufffd\ufffd')
...
unittest.main(exit=False)
F
==
FAIL:
15 matches
Mail list logo