Bug 1373363

Summary: Incorrect parsing of regular expressions
Product: Red Hat Enterprise Linux 7 Reporter: paulgraydon
Component: pythonAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED ERRATA QA Contact: Branislav Náter <bnater>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: apevec, bnater, cstratak, mbayer, pviktori
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-2.7.5-50.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 20:25:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1380359, 1393868    

Description paulgraydon 2016-09-06 06:07:26 UTC
Description of problem:

A bug was identified by the python developers that meant python incorrectly parsed certain regular expressions (http://bugs.python.org/issue18647).  This incorrect behaviour is present in the version of Python shipped with RHEL7, and may trip up unsuspecting users.  Not sure if, under the circumstances, you see value in backporting this fix.

Fixed by this commit https://github.com/python/cpython/commit/d30106dddd09af83ca5f0c49ac5a499f891dbdbe

If I'm reading the git history correctly, it looks like it was fixed ahead of the 2.7.6rc1 release.

Version-Release number of selected component (if applicable):


How reproducible:  Easy


Steps to Reproduce:

$ cat ~/bug.py
import re

re.compile("(?P<thing>\w*)?")
print "All OK!"

$ python ~/bug.py
Traceback (most recent call last):
  File "/home/opc/bug.py", line 3, in <module>
    re.compile("(?P<thing>\w*)?")
  File "/usr/lib64/python2.7/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib64/python2.7/re.py", line 242, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat


Expected results:

Should return "All OK!"


Additional info:

Comment 6 Charalampos Stratakis 2016-09-06 14:48:54 UTC
(In reply to paulgraydon from comment #0)
> Description of problem:
> 
> A bug was identified by the python developers that meant python incorrectly
> parsed certain regular expressions (http://bugs.python.org/issue18647). 
> This incorrect behaviour is present in the version of Python shipped with
> RHEL7, and may trip up unsuspecting users.  Not sure if, under the
> circumstances, you see value in backporting this fix.

Hello and thank you for the bug report.

The issue will be evaluated for a fix, however it's not high on the priority list at the moment.

Comment 9 Branislav Náter 2017-04-26 12:05:19 UTC
Reproduced on python-2.7.5-48.el7:

:: [  BEGIN   ] :: Run reproducer :: actually running 'python test.py'
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    re.compile("(?P<thing>\w*)?")
  File "/usr/lib64/python2.7/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib64/python2.7/re.py", line 242, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat
:: [   FAIL   ] :: Run reproducer (Expected 0, got 1)

Verified on python-2.7.5-57.el7:
Regular expression is correctly parsed

:: [  BEGIN   ] :: Run reproducer :: actually running 'python test.py'
:: [   PASS   ] :: Run reproducer (Expected 0, got 0)

Comment 10 errata-xmlrpc 2017-08-01 20:25:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:1868

Comment 11 Alan Pevec (Fedora) 2017-09-15 21:24:55 UTC
Heads up (will get proper BZ with reproducer filed later) this might have broken one of OpenStack deps: https://bugs.launchpad.net/tripleo/+bug/1717545