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: Different re results in Python 2.0 and 2.1a2
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: effbot Nosy List: effbot, kopfarzt
Priority: normal Keywords:

Created on 2001-02-20 17:52 by kopfarzt, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (2)
msg3521 - (view) Author: Kopf Arzt (kopfarzt) Date: 2001-02-20 17:52
The following program produces different results in Python2.0 (1.6, 1.5.2) and Python 2.1a2:

import re
rx = re.compile (r'"(?:\\"|[^"])*?"')
print rx.match (r'"\""').group (0) 

(match a double quoted string with backslash escaped quotes)

Python 1.5.2, 1.6, 2.0: "\""
Python 2.1a2: "\"

Thanks
Peter
msg3522 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2001-02-21 07:05
rx = re.compile (r'"(?:\\"|[^"]){,100}?"') works.

the bug is caused by an (obviously failed) attempt to minimize recursion for "*?".  the checkin message says "I'm not 100% sure about this fix, but I haven't managed to come up with any test case it cannot handle...".  guess this is it ;-)

Thanks /F
History
Date User Action Args
2022-04-10 16:03:46adminsetgithub: 33977
2001-02-20 17:52:21kopfarztcreate