RegexTest fails with python3.6

Bug #1665266 reported by Zac Medico on 2017-02-16
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mox3
Undecided
Unassigned

Bug Description

RegexTest fails as follows with python3.6:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/mox3-0.12.0/work/mox3-0.12.0/mox3/tests/test_mox.py", line 319, in testReprWithFlags
    self.assertTrue(repr(mox.Regex(r"a\s+b", flags=4)) ==
  File "/var/tmp/portage/dev-python/mox3-0.12.0/work/mox3-0.12.0/mox3/mox.py", line 1530, in __init__
    self.regex = re.compile(pattern, flags=flags)
  File "/usr/lib64/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/usr/lib64/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib64/python3.6/sre_parse.py", line 866, in parse
    p.pattern.flags = fix_flags(str, p.pattern.flags)
  File "/usr/lib64/python3.6/sre_parse.py", line 833, in fix_flags
    raise ValueError("cannot use LOCALE flag with a str pattern")
ValueError: cannot use LOCALE flag with a str pattern

If flags=4 is changed to flags=8, then it fails like this:

Traceback (most recent call last):
  File "mox3/tests/test_mox.py", line 315, in testReprWithoutFlags
    repr(mox.Regex(r"a\\s+b")) == "<regular expression 'a\s+b'>")
  File "/usr/lib64/python2.7/site-packages/unittest2/case.py", line 702, in assertTrue
    raise self.failureException(msg)
AssertionError: False is not true

The attached patch fixes these problems.

Zac Medico (zmedico) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers