Skip to content

Commit 3c16e2c

Browse files
committed
Fix flags handling for fallback compiler
1 parent 8253cea commit 3c16e2c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

graalpython/lib-graalpython/_sre.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, compiled_pattern, flags, sticky):
7777
self.__compiled_pattern__ = compiled_pattern
7878
self.__sticky__ = sticky
7979
self.pattern = compiled_pattern.pattern
80-
self.flags = flags
80+
self.flags = {name: bool(flags & flag) for flag, name in FLAG_NAMES}
8181
self.groupCount = 1 + compiled_pattern.groups
8282
self.groups = _NamedCaptureGroups(compiled_pattern.groupindex)
8383

@@ -111,7 +111,7 @@ def fallback_compiler(pattern, flags):
111111

112112
compiled_pattern = _sre_compile(pattern, bit_flags)
113113

114-
return _ExecutablePattern(compiled_pattern, flags, sticky)
114+
return _ExecutablePattern(compiled_pattern, bit_flags, sticky)
115115

116116
def _new_compile(p, flags=0):
117117
if _with_tregex and isinstance(p, (str, bytes)):
@@ -292,9 +292,10 @@ def __init__(self, pattern, flags):
292292
def flags(self):
293293
# Flags can be spcified both in the flag argument or inline in the regex. Extract them back from the regex
294294
flags = self.__input_flags
295+
regex_flags = self.__tregex_compile(self.pattern).flags
295296
for flag, name in FLAG_NAMES:
296297
try:
297-
if self.__tregex_compile(self.pattern).flags[name]:
298+
if regex_flags[name]:
298299
flags |= flag
299300
except KeyError:
300301
pass

0 commit comments

Comments
 (0)