This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error compiling valid regex
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder: Adding a new regex module (compatible with re)
View: 2636
Assigned To: Nosy List: Eloff, crchemist, ezio.melotti, georg.brandl, mrabarnett, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2009-05-31 16:26 by Eloff, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_re.py.patch crchemist, 2009-06-01 15:54 patch for Lib/test/test_re.py
sre_compile.py.patch crchemist, 2009-06-01 15:59 patch for Lib/sre_compile.py
Messages (8)
msg88600 - (view) Author: Daniel Eloff (Eloff) Date: 2009-05-31 16:26
This works:

r'([xy])(?:\1)+'

This won't compile, "error: nothing to repeat"

r'([xy])(?:\s*\1)+'

I can execute this under other regex engines, and it seems to me that it
really should work.
msg88605 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2009-05-31 19:58
I agree that it's a bug.

A workaround is r'([xy])(?:\s{0,65534}\1)+'. A repeat of 65535 is
treated as unlimited (but no warning is given).
msg88646 - (view) Author: Mykola Kharechko (crchemist) Date: 2009-06-01 15:54
tests for this issue.
msg88649 - (view) Author: Mykola Kharechko (crchemist) Date: 2009-06-01 15:59
patch that fix this
msg88662 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-06-01 18:01
Just taking out the "raise" seems questionable to me; are you sure there
are no valid errors that can be caught there?
msg88667 - (view) Author: Mykola Kharechko (crchemist) Date: 2009-06-01 19:35
> are you sure there are no valid errors that can be caught there?
Sorry, No. See
http://svn.python.org/view/python/trunk/Lib/sre_compile.py?r1=17949&r2=17948&pathrev=17949
and http://osdir.com/ml/python.bugs/2000-10/msg00010.html links.
msg111980 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-29 17:47
Closing in favor of #2636, which allows this regex to be compiled.
msg306512 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-19 19:44
This issue was fixed in issue9179.

The issue with 65535 repeats was fixed in issue13169.
History
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50406
2017-11-19 19:44:16serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg306512
2010-07-29 17:47:04georg.brandlsetstatus: open -> closed
resolution: out of date
superseder: Adding a new regex module (compatible with re)
messages: + msg111980
2009-06-02 17:31:09ezio.melottisetnosy: + ezio.melotti

versions: + Python 3.0
2009-06-01 19:35:04crchemistsetmessages: + msg88667
2009-06-01 18:01:48georg.brandlsetnosy: + georg.brandl
messages: + msg88662
2009-06-01 15:59:37crchemistsetfiles: + sre_compile.py.patch

messages: + msg88649
2009-06-01 15:54:02crchemistsetfiles: + test_re.py.patch

nosy: + crchemist
messages: + msg88646

keywords: + patch
2009-05-31 19:59:00mrabarnettsetnosy: + mrabarnett
messages: + msg88605
2009-05-31 16:26:01Eloffcreate