File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
graalpython/lib-graalpython Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -244,22 +244,22 @@ def _is_bytes_like(object):
244
244
class SRE_Pattern ():
245
245
def __init__ (self , pattern , flags ):
246
246
self .__binary = isinstance (pattern , bytes )
247
- self .groups = 0
248
247
self .pattern = pattern
249
248
self .flags = flags
250
249
flags_str = []
251
250
for char ,flag in FLAGS .items ():
252
251
if flags & flag :
253
252
flags_str .append (char )
254
253
self .flags_str = "" .join (flags_str )
255
- self .__compiled_regexes = dict ()
256
- groupindex = dict ()
257
- if self .__tregex_compile (self .pattern ).groups is not None :
258
- for group_name in dir (self .__tregex_compile (self .pattern ).groups ):
259
- groups = self .__tregex_compile (self .pattern ).groups
260
- self .groups = len (dir (groups ))
261
- groupindex [group_name ] = groups [group_name ]
262
- self .groupindex = _mappingproxy (groupindex )
254
+ self .__compiled_regexes = {}
255
+ compiled_regex = self .__tregex_compile (self .pattern )
256
+ self .groups = compiled_regex .groupCount - 1
257
+ groups = compiled_regex .groups
258
+ if groups is None :
259
+ self .groupindex = {}
260
+ else :
261
+ group_names = dir (groups )
262
+ self .groupindex = _mappingproxy ({name : groups [name ] for name in group_names })
263
263
264
264
def __check_input_type (self , input ):
265
265
if not isinstance (input , str ) and not _is_bytes_like (input ):
You can’t perform that action at this time.
0 commit comments