@@ -77,7 +77,7 @@ def __init__(self, compiled_pattern, flags, sticky):
77
77
self .__compiled_pattern__ = compiled_pattern
78
78
self .__sticky__ = sticky
79
79
self .pattern = compiled_pattern .pattern
80
- self .flags = flags
80
+ self .flags = { name : bool ( flags & flag ) for flag , name in FLAG_NAMES }
81
81
self .groupCount = 1 + compiled_pattern .groups
82
82
self .groups = _NamedCaptureGroups (compiled_pattern .groupindex )
83
83
@@ -111,7 +111,7 @@ def fallback_compiler(pattern, flags):
111
111
112
112
compiled_pattern = _sre_compile (pattern , bit_flags )
113
113
114
- return _ExecutablePattern (compiled_pattern , flags , sticky )
114
+ return _ExecutablePattern (compiled_pattern , bit_flags , sticky )
115
115
116
116
def _new_compile (p , flags = 0 ):
117
117
if _with_tregex and isinstance (p , (str , bytes )):
@@ -292,9 +292,10 @@ def __init__(self, pattern, flags):
292
292
def flags (self ):
293
293
# Flags can be spcified both in the flag argument or inline in the regex. Extract them back from the regex
294
294
flags = self .__input_flags
295
+ regex_flags = self .__tregex_compile (self .pattern ).flags
295
296
for flag , name in FLAG_NAMES :
296
297
try :
297
- if self . __tregex_compile ( self . pattern ). flags [name ]:
298
+ if regex_flags [name ]:
298
299
flags |= flag
299
300
except KeyError :
300
301
pass
0 commit comments