-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-31690: Make "a", "L" and "u" inline flags in regular expressions local. #3885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8d85e3d
68275d3
c13cb5d
6622170
71449b9
6658108
e39547d
a367480
0b2b351
9748964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
|
|
||
| # update when constants are added or removed | ||
|
|
||
| MAGIC = 20170530 | ||
| MAGIC = 20171005 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This occurred to me during the previous discussion regarding optimization efforts for The reason is that compiled regular expressions can be pickled. If I pickle a regex using Python 3.7.0 and the format changes for 3.7.1, then my compiled regexps will not be unpicklable, right? I haven't actually analyzed the regex pickle format, so I could be wrong about that, but if I'm right, then I think that's a problem.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regex pickle format just contains a text pattern and integer flags. When unpickled re.compile() just is called. This format is compatible while the syntax of regular expressions is compatible. |
||
|
|
||
| from _sre import MAXREPEAT, MAXGROUPS | ||
|
|
||
|
|
@@ -84,25 +84,37 @@ def _makecodes(names): | |
| CALL | ||
| CATEGORY | ||
| CHARSET BIGCHARSET | ||
| GROUPREF GROUPREF_EXISTS GROUPREF_IGNORE | ||
| IN IN_IGNORE | ||
| GROUPREF GROUPREF_EXISTS | ||
| IN | ||
| INFO | ||
| JUMP | ||
| LITERAL LITERAL_IGNORE | ||
| LITERAL | ||
| MARK | ||
| MAX_UNTIL | ||
| MIN_UNTIL | ||
| NOT_LITERAL NOT_LITERAL_IGNORE | ||
| NOT_LITERAL | ||
| NEGATE | ||
| RANGE | ||
| REPEAT | ||
| REPEAT_ONE | ||
| SUBPATTERN | ||
| MIN_REPEAT_ONE | ||
| RANGE_IGNORE | ||
|
|
||
| GROUPREF_IGNORE | ||
| IN_IGNORE | ||
| LITERAL_IGNORE | ||
| NOT_LITERAL_IGNORE | ||
|
|
||
| GROUPREF_LOC_IGNORE | ||
| IN_LOC_IGNORE | ||
| LITERAL_LOC_IGNORE | ||
| NOT_LITERAL_LOC_IGNORE | ||
| IN_LOC_IGNORE | ||
|
|
||
| GROUPREF_UNI_IGNORE | ||
| IN_UNI_IGNORE | ||
| LITERAL_UNI_IGNORE | ||
| NOT_LITERAL_UNI_IGNORE | ||
| RANGE_UNI_IGNORE | ||
|
|
||
| MIN_REPEAT MAX_REPEAT | ||
| """) | ||
|
|
@@ -113,7 +125,9 @@ def _makecodes(names): | |
| AT_BEGINNING AT_BEGINNING_LINE AT_BEGINNING_STRING | ||
| AT_BOUNDARY AT_NON_BOUNDARY | ||
| AT_END AT_END_LINE AT_END_STRING | ||
|
|
||
| AT_LOC_BOUNDARY AT_LOC_NON_BOUNDARY | ||
|
|
||
| AT_UNI_BOUNDARY AT_UNI_NON_BOUNDARY | ||
| """) | ||
|
|
||
|
|
@@ -123,7 +137,9 @@ def _makecodes(names): | |
| CATEGORY_SPACE CATEGORY_NOT_SPACE | ||
| CATEGORY_WORD CATEGORY_NOT_WORD | ||
| CATEGORY_LINEBREAK CATEGORY_NOT_LINEBREAK | ||
|
|
||
| CATEGORY_LOC_WORD CATEGORY_LOC_NOT_WORD | ||
|
|
||
| CATEGORY_UNI_DIGIT CATEGORY_UNI_NOT_DIGIT | ||
| CATEGORY_UNI_SPACE CATEGORY_UNI_NOT_SPACE | ||
| CATEGORY_UNI_WORD CATEGORY_UNI_NOT_WORD | ||
|
|
@@ -133,18 +149,20 @@ def _makecodes(names): | |
|
|
||
| # replacement operations for "ignore case" mode | ||
| OP_IGNORE = { | ||
| GROUPREF: GROUPREF_IGNORE, | ||
| IN: IN_IGNORE, | ||
| LITERAL: LITERAL_IGNORE, | ||
| NOT_LITERAL: NOT_LITERAL_IGNORE, | ||
| RANGE: RANGE_IGNORE, | ||
| } | ||
|
|
||
| OP_LOC_IGNORE = { | ||
| OP_LOCALE_IGNORE = { | ||
| LITERAL: LITERAL_LOC_IGNORE, | ||
| NOT_LITERAL: NOT_LITERAL_LOC_IGNORE, | ||
| } | ||
|
|
||
| OP_UNICODE_IGNORE = { | ||
| LITERAL: LITERAL_UNI_IGNORE, | ||
| NOT_LITERAL: NOT_LITERAL_UNI_IGNORE, | ||
| } | ||
|
|
||
| AT_MULTILINE = { | ||
| AT_BEGINNING: AT_BEGINNING_LINE, | ||
| AT_END: AT_END_LINE | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a bullet list here? I'll leave that to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will take too much space. Maybe later I'll add a table somewhere.