Skip to content
This repository was archived by the owner on Dec 21, 2025. It is now read-only.

Fix Python 3.6 bug with re module flags - #153

Merged
dabeaz merged 2 commits into
dabeaz:masterfrom
astrofrog:fix-reflags-python3
Feb 15, 2018
Merged

dabeaz merged 2 commits into
dabeaz:masterfrom
astrofrog:fix-reflags-python3

Conversation

@astrofrog

@astrofrog astrofrog commented Feb 9, 2018 •

Copy link
Copy Markdown
Contributor

In Python 3.6, re module flags are RegexFlags instances, not integers. This leads to an issue when setting e.g. reflags=re.UNICODE which used to work in Python 2. This PR adds a regression test to illustrate the failure:

======================================================================
ERROR: test_lex_optimize4 (__main__.LexBuildOptionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tom/tmp/ply/test/opt4tab.py", line 4
    _lexreflags   = <RegexFlag.UNICODE: 32>
                    ^
SyntaxError: invalid syntax

----------------------------------------------------------------------
Ran 44 tests in 1.129s

FAILED (errors=1)

And I'll push a fix once I confirm that Travis fails.

@astrofrog astrofrog changed the title Fix Python 3 bug with re module flags Fix Python 3.6 bug with re module flags Feb 9, 2018
@astrofrog

Copy link
Copy Markdown
Contributor Author

As expected, Travis failed with only the regression test and is fixed with the second commit

@dabeaz
dabeaz merged commit 807d381 into dabeaz:master Feb 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants