(void) ALseterrorhandler(ErrorHandler);
#endif /* OLD_INTERFACE */
- /* Check for errors */
- if (PyErr_Occurred()) {
- error:
- Py_FatalError("can't initialize module al");
- }
+ error:
+ return;
}
#ifdef CD_CDROM /* only newer versions of the library */
PyDict_SetItemString(d, "CDROM", PyInt_FromLong((long) CD_CDROM));
#endif
-
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module cd");
}
static void
_inscode(PyObject *d, PyObject *de, char *name, int code)
{
- PyObject *u;
- PyObject *v;
+ PyObject *u = PyString_FromString(name);
+ PyObject *v = PyInt_FromLong((long) code);
- u = PyString_FromString(name);
- v = PyInt_FromLong((long) code);
-
- if (!u || !v) {
- /* Don't bother reporting this error */
- PyErr_Clear();
- }
- else {
+ /* Don't bother checking for errors; they'll be caught at the end
+ * of the module initialization function by the caller of
+ * initerrno().
+ */
+ if (u && v) {
/* insert in modules dict */
PyDict_SetItem(d, u, v);
/* insert in errorcode dict */
m = Py_InitModule3("errno", errno_methods, errno__doc__);
d = PyModule_GetDict(m);
de = PyDict_New();
- if (de == NULL || PyDict_SetItemString(d, "errorcode", de))
- Py_FatalError("can't initialize errno module");
+ if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
+ return;
/* Macro so I don't have to edit each and every line below... */
#define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code)
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
all_ins(d);
-
- /* Check for errors */
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module fcntl");
}
goto error;
Py_DECREF(x);
- /* Check for errors */
- if (PyErr_Occurred()) {
- error:
- Py_FatalError("can't initialize module linuxaudiodev");
- }
+ error:
+ return;
}
if (PyDict_SetItemString(d, "e", v) < 0)
goto finally;
Py_DECREF(v);
- return;
finally:
- Py_FatalError("can't initialize math module");
+ return;
}
/* create some frequently used constants */
if ((mpz_value_zero = newmpzobject()) == NULL)
- Py_FatalError("initmpz: can't initialize mpz constants");
+ goto finally;
mpz_set_ui(&mpz_value_zero->mpz, (unsigned long int)0);
if ((mpz_value_one = newmpzobject()) == NULL)
- Py_FatalError("initmpz: can't initialize mpz constants");
+ goto finally;
mpz_set_ui(&mpz_value_one->mpz, (unsigned long int)1);
if ((mpz_value_mone = newmpzobject()) == NULL)
- Py_FatalError("initmpz: can't initialize mpz constants");
+ goto finally;
mpz_set_si(&mpz_value_mone->mpz, (long)-1);
dict = PyModule_GetDict(module);
if (dict != NULL) {
PyDict_SetItemString(dict, "MPZType", (PyObject*)&MPZtype);
}
-
+ finally:
+ return;
} /* initmpz() */
+
#ifdef MAKEDUMMYINT
int _mpz_dummy_int; /* XXX otherwise, we're .bss-less (DYNLOAD->Jack?) */
#endif /* def MAKEDUMMYINT */
parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
if ((parser_error == 0)
- || (PyDict_SetItemString(dict, "ParserError", parser_error) != 0)) {
- /*
- * This is serious.
- */
- Py_FatalError("can't define parser.ParserError");
+ || (PyDict_SetItemString(dict, "ParserError", parser_error) != 0))
+ {
+ /* caller will check PyErr_Occurred() */
+ return;
}
/*
* Nice to have, but don't cry if we fail.
insint(d, "DOTALL", PCRE_DOTALL);
insint(d, "VERBOSE", PCRE_EXTENDED);
insint(d, "LOCALE", PCRE_LOCALE);
-
- /* Check for errors */
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module pcre");
}
#else
PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None);
#endif
- if (PyErr_Occurred())
- Py_FatalError("couldn't initialize the pure module");
}
functions require an integral number of
blocks */
insint("digestsize", 20);
-
- /* Check for errors */
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module SHA");
}
PyDict_SetItemString(d, "uppercase", s);
Py_DECREF(s);
}
-
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module strop");
}
ins(d, "LOG_CRON", LOG_CRON);
ins(d, "LOG_UUCP", LOG_UUCP);
ins(d, "LOG_NEWS", LOG_NEWS);
-
- /* Check for errors */
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module syslog");
}
static void
ins(PyObject *d, char *name, PyObject *v)
{
- if (v == NULL)
- Py_FatalError("Can't initialize time module -- NULL value");
- if (PyDict_SetItemString(d, name, v) != 0)
- Py_FatalError(
- "Can't initialize time module -- PyDict_SetItemString failed");
- Py_DECREF(v);
+ /* Don't worry too much about errors, they'll be caught by the
+ * caller of inittime().
+ */
+ if (v)
+ PyDict_SetItemString(d, name, v);
+ Py_XDECREF(v);
}
+
static char module_doc[] =
"This module provides various functions to manipulate time values.\n\
\n\
#endif /* macintosh */
#endif /* HAVE_TM_ZONE */
#endif /* !HAVE_TZNAME || __GLIBC__ */
- if (PyErr_Occurred())
- Py_FatalError("Can't initialize time module");
}
DL_EXPORT(void) inittiming(void)
{
(void)Py_InitModule("timing", timing_methods);
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module timing");
}