diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_struct.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-1a21451b1d73b65af949193208372e86bf308411.zip cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2 |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index ae8a160..e7cbd4b 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2087,28 +2087,41 @@ Whitespace between formats is ignored.\n\ \n\ The variable struct.error is an exception raised on errors.\n"); + +static struct PyModuleDef _structmodule = { + PyModuleDef_HEAD_INIT, + "_struct", + module_doc, + -1, + module_functions, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_struct(void) +PyInit__struct(void) { PyObject *ver, *m; ver = PyBytes_FromString("0.2"); if (ver == NULL) - return; + return NULL; - m = Py_InitModule3("_struct", module_functions, module_doc); + m = PyModule_Create(&_structmodule); if (m == NULL) - return; + return NULL; Py_TYPE(&PyStructType) = &PyType_Type; if (PyType_Ready(&PyStructType) < 0) - return; + return NULL; #ifdef PY_STRUCT_OVERFLOW_MASKING if (pyint_zero == NULL) { pyint_zero = PyLong_FromLong(0); if (pyint_zero == NULL) - return; + return NULL; } if (pylong_ulong_mask == NULL) { #if (SIZEOF_LONG == 4) @@ -2117,7 +2130,7 @@ init_struct(void) pylong_ulong_mask = PyLong_FromString("FFFFFFFFFFFFFFFF", NULL, 16); #endif if (pylong_ulong_mask == NULL) - return; + return NULL; } #else @@ -2168,7 +2181,7 @@ init_struct(void) if (StructError == NULL) { StructError = PyErr_NewException("struct.error", NULL, NULL); if (StructError == NULL) - return; + return NULL; } Py_INCREF(StructError); @@ -2186,5 +2199,6 @@ init_struct(void) #ifdef PY_STRUCT_FLOAT_COERCE PyModule_AddIntConstant(m, "_PY_STRUCT_FLOAT_COERCE", 1); #endif + return m; } |