New submission from Quentin Wenger <wenger.quen...@bluewin.ch>:

This seems somewhat arbitrary and yields unusable results, going against the 
doc:

> repr(object)
> Return a string containing a printable representation of an object. For many 
> types, this function makes an attempt to return a string that would yield an 
> object with the same value when passed to eval(), otherwise the 
> representation is a string enclosed in angle brackets that contains the name 
> of the type of the object together with additional information often 
> including the name and address of the object. A class can control what this 
> function returns for its instances by defining a __repr__() method.

The truncated representation neither "yields an object with the same value" (it 
raises a SyntaxError, of course, due to the missing quote and closing 
parenthesis), nor is "enclosed in angle brackets".


```
>>> import re
>>> re.compile("()"*99)
re.compile('()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()')
>>> re.compile("()"*100)
re.compile('()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
```

----------
components: Regular Expressions
messages: 371541
nosy: ezio.melotti, matpi, mrabarnett
priority: normal
severity: normal
status: open
title: re.compile's repr truncates patterns at 199 characters
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40984>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to