@@ -1863,13 +1863,40 @@ static PyMethodDef speedups_methods[] = {
1863
1863
PyDoc_STRVAR (module_doc ,
1864
1864
"json speedups\n" );
1865
1865
1866
+ static int
1867
+ _json_exec (PyObject * module )
1868
+ {
1869
+ if (PyType_Ready (& PyScannerType ) < 0 ) {
1870
+ return -1 ;
1871
+ }
1872
+ if (PyType_Ready (& PyEncoderType ) < 0 ) {
1873
+ return -1 ;
1874
+ }
1875
+ Py_INCREF ((PyObject * )& PyScannerType );
1876
+ if (PyModule_AddObject (module , "make_scanner" , (PyObject * )& PyScannerType ) < 0 ) {
1877
+ Py_DECREF ((PyObject * )& PyScannerType );
1878
+ return -1 ;
1879
+ }
1880
+ Py_INCREF ((PyObject * )& PyEncoderType );
1881
+ if (PyModule_AddObject (module , "make_encoder" , (PyObject * )& PyEncoderType ) < 0 ) {
1882
+ Py_DECREF ((PyObject * )& PyEncoderType );
1883
+ return -1 ;
1884
+ }
1885
+ return 0 ;
1886
+ }
1887
+
1888
+ static PyModuleDef_Slot _json_slots [] = {
1889
+ {Py_mod_exec , _json_exec },
1890
+ {0 , NULL }
1891
+ };
1892
+
1866
1893
static struct PyModuleDef jsonmodule = {
1867
1894
PyModuleDef_HEAD_INIT ,
1868
1895
"_json" ,
1869
1896
module_doc ,
1870
- -1 ,
1897
+ 0 ,
1871
1898
speedups_methods ,
1872
- NULL ,
1899
+ _json_slots ,
1873
1900
NULL ,
1874
1901
NULL ,
1875
1902
NULL
@@ -1878,25 +1905,5 @@ static struct PyModuleDef jsonmodule = {
1878
1905
PyMODINIT_FUNC
1879
1906
PyInit__json (void )
1880
1907
{
1881
- PyObject * m = PyModule_Create (& jsonmodule );
1882
- if (!m )
1883
- return NULL ;
1884
- if (PyType_Ready (& PyScannerType ) < 0 )
1885
- goto fail ;
1886
- if (PyType_Ready (& PyEncoderType ) < 0 )
1887
- goto fail ;
1888
- Py_INCREF ((PyObject * )& PyScannerType );
1889
- if (PyModule_AddObject (m , "make_scanner" , (PyObject * )& PyScannerType ) < 0 ) {
1890
- Py_DECREF ((PyObject * )& PyScannerType );
1891
- goto fail ;
1892
- }
1893
- Py_INCREF ((PyObject * )& PyEncoderType );
1894
- if (PyModule_AddObject (m , "make_encoder" , (PyObject * )& PyEncoderType ) < 0 ) {
1895
- Py_DECREF ((PyObject * )& PyEncoderType );
1896
- goto fail ;
1897
- }
1898
- return m ;
1899
- fail :
1900
- Py_DECREF (m );
1901
- return NULL ;
1908
+ return PyModuleDef_Init (& jsonmodule );
1902
1909
}
0 commit comments