[issue40984] re.compile's repr truncates patterns at 200 characters

Quentin Wenger report at bugs.python.org
Tue Jun 16 05:59:08 EDT 2020


Quentin Wenger <wenger.quentin at bluewin.ch> added the comment:

Pardon me, but I see an important difference with the other bug report: that one is about a repr in angle brackets, and as such does not require an exact output, so an ellipsis is good enough.

In this bug, the output of repr gives a string than can, at least for small enough patterns, be passed to eval() to recontruct an object. So there is no good reason that this can be done for patterns up to 200 characters but not above; furthermore it is undocumented and goes against the doc on repr.

Compare with a complexly-nested structure of, say, lists, dicts and strings: The repr will always be "reconstructible", even if it is well above 200 characters.

Also, a common way to write repr is to draw the outer "container" as a string, and fill it with the (full!) repr of the object's parameters. E.g. the repr of a list containing a 1000-character string will simply write square brackets around the 1002-character repr of the string. re.compile doesn't conform to this "rule".

----------
resolution: duplicate -> 
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40984>
_______________________________________


More information about the Python-bugs-list mailing list