@@ -1384,12 +1384,24 @@ static PyMethodDef pattern_methods[] = {
13841384 {NULL , NULL }
13851385};
13861386
1387+ /* PatternObject's 'groupindex' method. */
1388+ static PyObject *
1389+ pattern_groupindex (PatternObject * self )
1390+ {
1391+ return PyDictProxy_New (self -> groupindex );
1392+ }
1393+
1394+ static PyGetSetDef pattern_getset [] = {
1395+ {"groupindex" , (getter )pattern_groupindex , (setter )NULL ,
1396+ "A dictionary mapping group names to group numbers." },
1397+ {NULL } /* Sentinel */
1398+ };
1399+
13871400#define PAT_OFF (x ) offsetof(PatternObject, x)
13881401static PyMemberDef pattern_members [] = {
13891402 {"pattern" , T_OBJECT , PAT_OFF (pattern ), READONLY },
13901403 {"flags" , T_INT , PAT_OFF (flags ), READONLY },
13911404 {"groups" , T_PYSSIZET , PAT_OFF (groups ), READONLY },
1392- {"groupindex" , T_OBJECT , PAT_OFF (groupindex ), READONLY },
13931405 {NULL } /* Sentinel */
13941406};
13951407
@@ -1422,6 +1434,7 @@ static PyTypeObject Pattern_Type = {
14221434 0 , /* tp_iternext */
14231435 pattern_methods , /* tp_methods */
14241436 pattern_members , /* tp_members */
1437+ pattern_getset , /* tp_getset */
14251438};
14261439
14271440static int _validate (PatternObject * self ); /* Forward */
0 commit comments