@@ -39,13 +39,14 @@ static const char copyright[] =
39
39
" SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB " ;
40
40
41
41
#include "Python.h"
42
- #include "pycore_dict.h" // _PyDict_Next()
43
- #include "pycore_long.h" // _PyLong_GetZero()
44
- #include "pycore_moduleobject.h" // _PyModule_GetState()
42
+ #include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
43
+ #include "pycore_dict.h" // _PyDict_Next()
44
+ #include "pycore_long.h" // _PyLong_GetZero()
45
+ #include "pycore_moduleobject.h" // _PyModule_GetState()
45
46
46
- #include "sre.h" // SRE_CODE
47
+ #include "sre.h" // SRE_CODE
47
48
48
- #include <ctype.h> // tolower(), toupper(), isalnum()
49
+ #include <ctype.h> // tolower(), toupper(), isalnum()
49
50
50
51
#define SRE_CODE_BITS (8 * sizeof(SRE_CODE))
51
52
@@ -2349,26 +2350,28 @@ _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value)
2349
2350
if (!result || !self -> pattern -> groupindex )
2350
2351
return result ;
2351
2352
2353
+ Py_BEGIN_CRITICAL_SECTION (self -> pattern -> groupindex );
2352
2354
while (_PyDict_Next (self -> pattern -> groupindex , & pos , & key , & value , & hash )) {
2353
2355
int status ;
2354
2356
Py_INCREF (key );
2355
2357
value = match_getslice (self , key , default_value );
2356
2358
if (!value ) {
2357
2359
Py_DECREF (key );
2358
- goto failed ;
2360
+ Py_CLEAR (result );
2361
+ goto exit ;
2359
2362
}
2360
2363
status = _PyDict_SetItem_KnownHash (result , key , value , hash );
2361
2364
Py_DECREF (value );
2362
2365
Py_DECREF (key );
2363
- if (status < 0 )
2364
- goto failed ;
2366
+ if (status < 0 ) {
2367
+ Py_CLEAR (result );
2368
+ goto exit ;
2369
+ }
2365
2370
}
2371
+ exit :
2372
+ Py_END_CRITICAL_SECTION ();
2366
2373
2367
2374
return result ;
2368
-
2369
- failed :
2370
- Py_DECREF (result );
2371
- return NULL ;
2372
2375
}
2373
2376
2374
2377
/*[clinic input]
0 commit comments