Message104989
> 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 lengths, at least more often.
'replace' loose important informations: if the test is about the unicode string content, we will be unable to see the error data.
Result of the first example with my patch (backslashreplace):
======================================================================
FAIL: test_fffd (__main__.Foo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "x.py", line 3, in test_fffd
def test_fffd(self): self.assertEqual(u'\ufffd', u'\ufffd\ufffd')
AssertionError:
- \ufffd+ \ufffd\ufffd
Result of the first example with 'replace' error handler:
======================================================================
FAIL: test_fffd (__main__.Foo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "x.py", line 3, in test_fffd
def test_fffd(self): self.assertEqual(u'\ufffd', u'\ufffd\ufffd')
AssertionError:
- ?+ ??
(but this example is irrevelant because U+FFFD is the unicode replacement character :-D)
If nobody complains about my patch, I will commit it to Python trunk (only).
You can still reimplement fail() method to encode the message using a more revelant encoding and/or error handler. |
|
Date |
User |
Action |
Args |
2010-05-05 00:32:24 | vstinner | set | recipients:
+ vstinner, amaury.forgeotdarc, ezio.melotti, michael.foord, gthb |
2010-05-05 00:32:24 | vstinner | set | messageid: <1273019544.11.0.438727249101.issue8313@psf.upfronthosting.co.za> |
2010-05-05 00:32:21 | vstinner | link | issue8313 messages |
2010-05-05 00:32:20 | vstinner | create | |
|