File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -2773,6 +2773,17 @@ static struct PyModuleDef sremodule = {
2773
2773
NULL
2774
2774
};
2775
2775
2776
+ #define ADD_ULONG_CONSTANT (module , name , value ) \
2777
+ do { \
2778
+ PyObject *o = PyLong_FromUnsignedLong(value); \
2779
+ if (!o) \
2780
+ return NULL; \
2781
+ if (PyModule_AddObject(module, name, o) < 0) { \
2782
+ Py_DECREF(o); \
2783
+ return NULL; \
2784
+ } \
2785
+ } while (0)
2786
+
2776
2787
PyMODINIT_FUNC PyInit__sre (void )
2777
2788
{
2778
2789
PyObject * m ;
@@ -2794,13 +2805,8 @@ PyMODINIT_FUNC PyInit__sre(void)
2794
2805
return NULL ;
2795
2806
}
2796
2807
2797
- if (PyModule_AddIntConstant (m , "MAXREPEAT" , SRE_MAXREPEAT ) < 0 ) {
2798
- return NULL ;
2799
- }
2800
-
2801
- if (PyModule_AddIntConstant (m , "MAXGROUPS" , SRE_MAXGROUPS ) < 0 ) {
2802
- return NULL ;
2803
- }
2808
+ ADD_ULONG_CONSTANT (m , "MAXREPEAT" , SRE_MAXREPEAT );
2809
+ ADD_ULONG_CONSTANT (m , "MAXGROUPS" , SRE_MAXGROUPS );
2804
2810
2805
2811
if (PyModule_AddStringConstant (m , "copyright" , copyright ) < 0 ) {
2806
2812
return NULL ;
You can’t perform that action at this time.
0 commit comments