[ python-Bugs-1065427 ] sre_parse group limit check missing with 'python -O'

SourceForge.net noreply at sourceforge.net
Sat Nov 13 08:02:01 CET 2004


Bugs item #1065427, was opened at 2004-11-12 21:46
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1065427&group_id=5470

Category: Regular Expressions
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Sam Rushing (rushing)
Assigned to: Fredrik Lundh (effbot)
Summary: sre_parse group limit check missing with 'python -O'

Initial Comment:
sre_parse.py includes a check to ensure that the
hard-coded limit of 100 groups is not exceeded.
Since the check uses an assert(), it's not present
when running in '-O' mode, so you can easily segfault
the re engine:

rushing at fang:~$ /usr/local/bin/python -O
Python 2.3.4 (#2, Oct 23 2004, 05:24:36) 
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
>>> import re
>>> p = re.compile ('(' + '|'.join (['(xxx)']*200) + ')')
>>> p.search ('asdfasdfasdfasdfasdf')
Segmentation fault (core dumped)

The assert() should be changed to an 'if/raise'.

NOTE: I've sent changes to Frederik to remove the
limitation altogether - so if those get in before this
bug is addressed then please ignore.


----------------------------------------------------------------------

>Comment By: Fredrik Lundh (effbot)
Date: 2004-11-13 08:02

Message:
Logged In: YES 
user_id=38376

This was changed in 2.4b1 (didn't I mail you about this?):

>>> p = re.compile ('(' + '|'.join (['(xxx)']*200) + ')')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/fredrik/NOBACKUP/python-
dev/python/dist/src/Lib/sre.py", line 180, in compile
    return _compile(pattern, flags)
  File "/home/fredrik/NOBACKUP/python-
dev/python/dist/src/Lib/sre.py", line 225, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/home/fredrik/NOBACKUP/python-
dev/python/dist/src/Lib/sre_compile.py", line 506, in compile
    raise AssertionError(
AssertionError: sorry, but this version only supports 100 
named groups

As for the real fix, it arrived too close to the beta release, 
and while it looks pretty solid, I'm not sure if it's a good idea 
to add it this close to a major release.  I'll bring this up on 
python-dev, when I find the time.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1065427&group_id=5470


More information about the Python-bugs-list mailing list