Improve the docstring further
This commit is contained in:
parent
e7ed45a5d4
commit
79c2a47985
|
@ -327,12 +327,15 @@ def rewrite_asserts(mod):
|
||||||
|
|
||||||
|
|
||||||
def _saferepr(obj):
|
def _saferepr(obj):
|
||||||
"""Get a safe repr of an object for assertion error messages
|
"""Get a safe repr of an object for assertion error messages.
|
||||||
|
|
||||||
The assertion formatting (util.format_explanation()) requires
|
The assertion formatting (util.format_explanation()) requires
|
||||||
newlines to be escaped since they are a special character for it.
|
newlines to be escaped since they are a special character for it.
|
||||||
But py.io.saferepr allows newlines, so we need to escape them
|
Normally assertion.util.format_explanation() does this but for a
|
||||||
here.
|
custom repr it is possible to contain one of the special escape
|
||||||
|
sequences, especially '\n{' and '\n}' are likely to be present in
|
||||||
|
JSON reprs.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
repr = py.io.saferepr(obj)
|
repr = py.io.saferepr(obj)
|
||||||
if py.builtin._istext(repr):
|
if py.builtin._istext(repr):
|
||||||
|
|
Loading…
Reference in New Issue