mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Apply two changes, systematically:
(1) Use PyErr_NewException("module.class", NULL, NULL) to create the exception object. (2) Remove all calls to Py_FatalError(); instead, return or ignore the errors -- the import code now checks PyErr_Occurred() after calling a module's init function, so it's no longer a fatal error for the initialization to fail. Also did some small cleanups, e.g. removed unnecessary test for "already initialized" from initfpectl(), and unified initposix()/initnt(). I haven't checked this very thoroughly, so while the changes are pretty trivial -- beware of untested code!
This commit is contained in:
parent
ccf0a44d2d
commit
0cb96de269
27 changed files with 79 additions and 167 deletions
|
@ -1535,7 +1535,7 @@ initcurses()
|
||||||
ModDict = d; /* For PyCurses_InitScr */
|
ModDict = d; /* For PyCurses_InitScr */
|
||||||
|
|
||||||
/* For exception curses.error */
|
/* For exception curses.error */
|
||||||
PyCursesError = PyString_FromString("curses.error");
|
PyCursesError = PyErr_NewException("curses.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", PyCursesError);
|
PyDict_SetItemString(d, "error", PyCursesError);
|
||||||
|
|
||||||
/* Make the version available */
|
/* Make the version available */
|
||||||
|
@ -1585,8 +1585,4 @@ initcurses()
|
||||||
SetDictInt("KEY_MIN", KEY_MIN);
|
SetDictInt("KEY_MIN", KEY_MIN);
|
||||||
SetDictInt("KEY_MAX", KEY_MAX);
|
SetDictInt("KEY_MAX", KEY_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module curses");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1396,8 +1396,7 @@ initaudioop()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("audioop", audioop_methods);
|
m = Py_InitModule("audioop", audioop_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
AudioopError = PyString_FromString("audioop.error");
|
AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
|
||||||
if ( AudioopError == NULL
|
if (AudioopError != NULL)
|
||||||
|| PyDict_SetItemString(d,"error",AudioopError) )
|
PyDict_SetItemString(d,"error",AudioopError);
|
||||||
Py_FatalError("can't define audioop.error");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,7 +746,7 @@ initbsddb() {
|
||||||
Bsddbtype.ob_type = &PyType_Type;
|
Bsddbtype.ob_type = &PyType_Type;
|
||||||
m = Py_InitModule("bsddb", bsddbmodule_methods);
|
m = Py_InitModule("bsddb", bsddbmodule_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
BsddbError = PyString_FromString("bsddb.error");
|
BsddbError = PyErr_NewException("bsddb.error", NULL, NULL);
|
||||||
if (BsddbError == NULL || PyDict_SetItemString(d, "error", BsddbError))
|
if (BsddbError != NULL)
|
||||||
Py_FatalError("can't define bsddb.error");
|
PyDict_SetItemString(d, "error", BsddbError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1006,7 +1006,7 @@ initcl()
|
||||||
m = Py_InitModule("cl", cl_methods);
|
m = Py_InitModule("cl", cl_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
ClError = PyString_FromString("cl.error");
|
ClError = PyErr_NewException("cl.error", NULL, NULL);
|
||||||
(void) PyDict_SetItemString(d, "error", ClError);
|
(void) PyDict_SetItemString(d, "error", ClError);
|
||||||
|
|
||||||
#ifdef CL_ADDED_ALGORITHM_ERROR
|
#ifdef CL_ADDED_ALGORITHM_ERROR
|
||||||
|
@ -2594,10 +2594,5 @@ initcl()
|
||||||
Py_DECREF(x);
|
Py_DECREF(x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
error:
|
|
||||||
Py_FatalError("can't initialize module cl");
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) clSetErrorHandler(cl_ErrorHandler);
|
(void) clSetErrorHandler(cl_ErrorHandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ initdbm() {
|
||||||
|
|
||||||
m = Py_InitModule("dbm", dbmmodule_methods);
|
m = Py_InitModule("dbm", dbmmodule_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
DbmError = PyString_FromString("dbm.error");
|
DbmError = PyErr_NewException("dbm.error", NULL, NULL);
|
||||||
if ( DbmError == NULL || PyDict_SetItemString(d, "error", DbmError) )
|
if (DbmError != NULL)
|
||||||
Py_FatalError("can't define dbm.error");
|
PyDict_SetItemString(d, "error", DbmError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,16 +229,18 @@ initdl()
|
||||||
PyObject *m, *d, *x;
|
PyObject *m, *d, *x;
|
||||||
|
|
||||||
if (sizeof(int) != sizeof(long) ||
|
if (sizeof(int) != sizeof(long) ||
|
||||||
sizeof(long) != sizeof(char *))
|
sizeof(long) != sizeof(char *)) {
|
||||||
Py_FatalError(
|
Py_Err_SetStr(
|
||||||
"module dl requires sizeof(int) == sizeof(long) == sizeof(char*)");
|
"module dl requires sizeof(int) == sizeof(long) == sizeof(char*)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the module and add the functions */
|
/* Create the module and add the functions */
|
||||||
m = Py_InitModule("dl", dl_methods);
|
m = Py_InitModule("dl", dl_methods);
|
||||||
|
|
||||||
/* Add some symbolic constants to the module */
|
/* Add some symbolic constants to the module */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
Dlerror = x = PyString_FromString("dl.error");
|
Dlerror = x = PyErr_NewException("dl.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", x);
|
PyDict_SetItemString(d, "error", x);
|
||||||
x = PyInt_FromLong((long)RTLD_LAZY);
|
x = PyInt_FromLong((long)RTLD_LAZY);
|
||||||
PyDict_SetItemString(d, "RTLD_LAZY", x);
|
PyDict_SetItemString(d, "RTLD_LAZY", x);
|
||||||
|
@ -246,8 +248,4 @@ initdl()
|
||||||
x = PyInt_FromLong((long)RTLD_NOW);
|
x = PyInt_FromLong((long)RTLD_NOW);
|
||||||
PyDict_SetItemString(d, "RTLD_NOW", x);
|
PyDict_SetItemString(d, "RTLD_NOW", x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module dl");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,17 +227,11 @@ static void sigfpe_handler(int signo)
|
||||||
void initfpectl(void)
|
void initfpectl(void)
|
||||||
{
|
{
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
static int already_initialized = 0;
|
|
||||||
|
|
||||||
if (already_initialized) return;
|
|
||||||
m = Py_InitModule("fpectl", fpectl_methods);
|
m = Py_InitModule("fpectl", fpectl_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
fpe_error = PyString_FromString("fpectl.error");
|
fpe_error = PyErr_NewException("fpectl.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", fpe_error);
|
if (fpe_error != NULL)
|
||||||
|
PyDict_SetItemString(d, "error", fpe_error);
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("Cannot initialize module fpectl");
|
|
||||||
already_initialized = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -178,9 +178,7 @@ void initfpetest(void)
|
||||||
|
|
||||||
m = Py_InitModule("fpetest", fpetest_methods);
|
m = Py_InitModule("fpetest", fpetest_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
fpe_error = PyString_FromString("fpetest.error");
|
fpe_error = PyErr_NewException("fpetest.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", fpe_error);
|
if (fpe_error != NULL)
|
||||||
|
PyDict_SetItemString(d, "error", fpe_error);
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("Cannot initialize module fpetest");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,7 +432,7 @@ initgdbm() {
|
||||||
|
|
||||||
m = Py_InitModule("gdbm", dbmmodule_methods);
|
m = Py_InitModule("gdbm", dbmmodule_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
DbmError = PyString_FromString("gdbm.error");
|
DbmError = PyErr_NewException("gdbm.error", NULL, NULL);
|
||||||
if ( DbmError == NULL || PyDict_SetItemString(d, "error", DbmError) )
|
if (DbmError != NULL)
|
||||||
Py_FatalError("can't define gdbm.error");
|
PyDict_SetItemString(d, "error", DbmError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -752,8 +752,7 @@ initimageop()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("imageop", imageop_methods);
|
m = Py_InitModule("imageop", imageop_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ImageopError = PyString_FromString("imageop.error");
|
ImageopError = PyErr_NewException("imageop.error", NULL, NULL);
|
||||||
if ( ImageopError == NULL ||
|
if (ImageopError != NULL)
|
||||||
PyDict_SetItemString(d,"error",ImageopError) )
|
PyDict_SetItemString(d, "error", ImageopError);
|
||||||
Py_FatalError("can't define imageop.error");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,10 +560,9 @@ initimgfile()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("imgfile", imgfile_methods);
|
m = Py_InitModule("imgfile", imgfile_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ImgfileError = PyString_FromString("imgfile.error");
|
ImgfileError = PyErr_NewException("imgfile.error", NULL, NULL);
|
||||||
if ( ImgfileError == NULL
|
if (ImgfileError != NULL)
|
||||||
|| PyDict_SetItemString(d, "error", ImgfileError) )
|
PyDict_SetItemString(d, "error", ImgfileError);
|
||||||
Py_FatalError("can't define imgfile.error");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -370,8 +370,7 @@ initnis ()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("nis", nis_methods);
|
m = Py_InitModule("nis", nis_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
NisError = PyString_FromString("nis.error");
|
NisError = PyErr_NewException("nis.error", NULL, NULL);
|
||||||
if (NisError == NULL ||
|
if (NisError != NULL)
|
||||||
PyDict_SetItemString(d, "error", NisError) != 0)
|
PyDict_SetItemString(d, "error", NisError);
|
||||||
Py_FatalError("Cannot define nis.error");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2254,73 +2254,37 @@ all_ins(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* XXX The following should be more unified -- only difference left is
|
|
||||||
function name and module name. */
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
||||||
|
#define INITFUNC initnt
|
||||||
|
#define MODNAME "nt"
|
||||||
|
#else
|
||||||
|
#define INITFUNC initposix
|
||||||
|
#define MODNAME "posix"
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
initnt()
|
INITFUNC()
|
||||||
{
|
{
|
||||||
PyObject *m, *d, *v;
|
PyObject *m, *d, *v;
|
||||||
|
|
||||||
m = Py_InitModule4("nt",
|
m = Py_InitModule4(MODNAME,
|
||||||
posix_methods,
|
posix_methods,
|
||||||
posix__doc__,
|
posix__doc__,
|
||||||
(PyObject *)NULL,
|
(PyObject *)NULL,
|
||||||
PYTHON_API_VERSION);
|
PYTHON_API_VERSION);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
/* Initialize nt.environ dictionary */
|
/* Initialize environ dictionary */
|
||||||
v = convertenviron();
|
v = convertenviron();
|
||||||
if (v == NULL || PyDict_SetItemString(d, "environ", v) != 0)
|
if (v == NULL || PyDict_SetItemString(d, "environ", v) != 0)
|
||||||
goto finally;
|
return;
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
|
|
||||||
if (all_ins(d))
|
if (all_ins(d))
|
||||||
goto finally;
|
|
||||||
|
|
||||||
/* Initialize nt.error exception */
|
|
||||||
PosixError = PyString_FromString("os.error");
|
|
||||||
PyDict_SetItemString(d, "error", PosixError);
|
|
||||||
|
|
||||||
if (!PyErr_Occurred())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
finally:
|
/* Initialize exception */
|
||||||
/* XXX Shouldn't */
|
PosixError = PyErr_NewException("os.error", NULL, NULL);
|
||||||
Py_FatalError("can't initialize NT posixmodule");
|
if (PosixError != NULL)
|
||||||
|
PyDict_SetItemString(d, "error", PosixError);
|
||||||
}
|
}
|
||||||
#else /* not a PC port */
|
|
||||||
void
|
|
||||||
initposix()
|
|
||||||
{
|
|
||||||
PyObject *m, *d, *v;
|
|
||||||
|
|
||||||
m = Py_InitModule4("posix",
|
|
||||||
posix_methods,
|
|
||||||
posix__doc__,
|
|
||||||
(PyObject *)NULL,
|
|
||||||
PYTHON_API_VERSION);
|
|
||||||
d = PyModule_GetDict(m);
|
|
||||||
|
|
||||||
/* Initialize posix.environ dictionary */
|
|
||||||
v = convertenviron();
|
|
||||||
if (v == NULL || PyDict_SetItemString(d, "environ", v) != 0)
|
|
||||||
goto finally;
|
|
||||||
Py_DECREF(v);
|
|
||||||
|
|
||||||
if (all_ins(d))
|
|
||||||
goto finally;
|
|
||||||
|
|
||||||
/* Initialize posix.error exception */
|
|
||||||
PosixError = PyString_FromString("os.error");
|
|
||||||
PyDict_SetItemString(d, "error", PosixError);
|
|
||||||
|
|
||||||
if (!PyErr_Occurred())
|
|
||||||
return;
|
|
||||||
|
|
||||||
finally:
|
|
||||||
/* XXX Shouldn't */
|
|
||||||
Py_FatalError("can't initialize posix module");
|
|
||||||
}
|
|
||||||
#endif /* !_MSC_VER */
|
|
||||||
|
|
|
@ -718,7 +718,7 @@ initregex()
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
/* Initialize regex.error exception */
|
/* Initialize regex.error exception */
|
||||||
v = RegexError = PyString_FromString("regex.error");
|
v = RegexError = PyErr_NewException("regex.error", NULL, NULL);
|
||||||
if (v == NULL || PyDict_SetItemString(d, "error", v) != 0)
|
if (v == NULL || PyDict_SetItemString(d, "error", v) != 0)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
|
@ -742,5 +742,5 @@ initregex()
|
||||||
if (!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
return;
|
return;
|
||||||
finally:
|
finally:
|
||||||
Py_FatalError("can't initialize regex module");
|
/* Nothing */ ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -958,7 +958,7 @@ initreop()
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
/* Initialize reop.error exception */
|
/* Initialize reop.error exception */
|
||||||
v = ReopError = PyString_FromString("reop.error");
|
v = ReopError = PyErr_NewException("reop.error", NULL, NULL);
|
||||||
if (v == NULL || PyDict_SetItemString(d, "error", v) != 0)
|
if (v == NULL || PyDict_SetItemString(d, "error", v) != 0)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
|
@ -1048,6 +1048,6 @@ initreop()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
Py_FatalError("can't initialize reop module");
|
/* Nothing */;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ void initresource()
|
||||||
|
|
||||||
/* Add some symbolic constants to the module */
|
/* Add some symbolic constants to the module */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ResourceError = PyString_FromString("resource.error");
|
ResourceError = PyErr_NewException("resource.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", ResourceError);
|
PyDict_SetItemString(d, "error", ResourceError);
|
||||||
|
|
||||||
/* insert constants */
|
/* insert constants */
|
||||||
|
@ -264,8 +264,4 @@ void initresource()
|
||||||
#ifdef RUSAGE_BOTH
|
#ifdef RUSAGE_BOTH
|
||||||
ins(d, "RUSAGE_BOTH", RUSAGE_BOTH);
|
ins(d, "RUSAGE_BOTH", RUSAGE_BOTH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module resource");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -782,9 +782,7 @@ initrgbimg()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("rgbimg", rgbimg_methods);
|
m = Py_InitModule("rgbimg", rgbimg_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ImgfileError = PyString_FromString("rgbimg.error");
|
ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL);
|
||||||
if (ImgfileError)
|
if (ImgfileError != NULL)
|
||||||
PyDict_SetItemString(d, "error", ImgfileError);
|
PyDict_SetItemString(d, "error", ImgfileError);
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize rgbimg module");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,8 +322,6 @@ initselect()
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
m = Py_InitModule("select", select_methods);
|
m = Py_InitModule("select", select_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
SelectError = PyString_FromString("select.error");
|
SelectError = PyErr_NewException("select.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", SelectError);
|
PyDict_SetItemString(d, "error", SelectError);
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("Cannot initialize select module");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1314,17 +1314,16 @@ static PyMethodDef PySocket_methods[] = {
|
||||||
|
|
||||||
/* Convenience routine to export an integer value.
|
/* Convenience routine to export an integer value.
|
||||||
*
|
*
|
||||||
* Since this function is called only from initsocket/init_socket(), any
|
* Errors are silently ignored, for better or for worse...
|
||||||
* errors trigger a fatal exception.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
BUILD_FUNC_DEF_3(insint,PyObject *,d, char *,name, int,value)
|
BUILD_FUNC_DEF_3(insint,PyObject *,d, char *,name, int,value)
|
||||||
{
|
{
|
||||||
PyObject *v = PyInt_FromLong((long) value);
|
PyObject *v = PyInt_FromLong((long) value);
|
||||||
if (!v || PyDict_SetItemString(d, name, v))
|
if (!v || PyDict_SetItemString(d, name, v))
|
||||||
Py_FatalError("can't initialize socket module");
|
PyErr_Clear();
|
||||||
|
|
||||||
Py_DECREF(v);
|
Py_XDECREF(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1398,15 +1397,15 @@ initsocket()
|
||||||
m = Py_InitModule("socket", PySocket_methods);
|
m = Py_InitModule("socket", PySocket_methods);
|
||||||
#endif
|
#endif
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
PySocket_Error = PyString_FromString("socket.error");
|
PySocket_Error = PyErr_NewException("socket.error", NULL, NULL);
|
||||||
if (PySocket_Error == NULL ||
|
if (PySocket_Error == NULL)
|
||||||
PyDict_SetItemString(d, "error", PySocket_Error) != 0)
|
return;
|
||||||
Py_FatalError("can't define socket.error");
|
PyDict_SetItemString(d, "error", PySocket_Error);
|
||||||
PySocketSock_Type.ob_type = &PyType_Type;
|
PySocketSock_Type.ob_type = &PyType_Type;
|
||||||
Py_INCREF(&PySocketSock_Type);
|
Py_INCREF(&PySocketSock_Type);
|
||||||
if (PyDict_SetItemString(d, "SocketType",
|
if (PyDict_SetItemString(d, "SocketType",
|
||||||
(PyObject *)&PySocketSock_Type) != 0)
|
(PyObject *)&PySocketSock_Type) != 0)
|
||||||
Py_FatalError("can't define socket.SocketType");
|
return;
|
||||||
insint(d, "AF_INET", AF_INET);
|
insint(d, "AF_INET", AF_INET);
|
||||||
#ifdef AF_UNIX
|
#ifdef AF_UNIX
|
||||||
insint(d, "AF_UNIX", AF_UNIX);
|
insint(d, "AF_UNIX", AF_UNIX);
|
||||||
|
|
|
@ -2651,13 +2651,11 @@ initstdwin()
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
/* Initialize stdwin.error exception */
|
/* Initialize stdwin.error exception */
|
||||||
StdwinError = PyString_FromString("stdwin.error");
|
StdwinError = PyErr_NewException("stdwin.error", NULL, NULL);
|
||||||
if (StdwinError == NULL ||
|
if (StdwinError == NULL ||
|
||||||
PyDict_SetItemString(d, "error", StdwinError) != 0)
|
PyDict_SetItemString(d, "error", StdwinError) != 0)
|
||||||
Py_FatalError("can't define stdwin.error");
|
return;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
StdwinLock = allocate_lock();
|
StdwinLock = allocate_lock();
|
||||||
if (StdwinLock == NULL)
|
|
||||||
Py_FatalError("can't allocate stdwin lock");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1298,10 +1298,8 @@ initstruct()
|
||||||
|
|
||||||
/* Add some symbolic constants to the module */
|
/* Add some symbolic constants to the module */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
StructError = PyString_FromString("struct.error");
|
StructError = PyErr_NewException("struct.error", NULL, NULL);
|
||||||
|
if (StructError == NULL)
|
||||||
|
return;
|
||||||
PyDict_SetItemString(d, "error", StructError);
|
PyDict_SetItemString(d, "error", StructError);
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module struct");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,9 +508,7 @@ initsunaudiodev()
|
||||||
|
|
||||||
m = Py_InitModule("sunaudiodev", sunaudiodev_methods);
|
m = Py_InitModule("sunaudiodev", sunaudiodev_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
SunAudioError = PyString_FromString("sunaudiodev.error");
|
SunAudioError = PyErr_NewException("sunaudiodev.error", NULL, NULL);
|
||||||
if (SunAudioError)
|
if (SunAudioError)
|
||||||
PyDict_SetItemString(d, "error", SunAudioError);
|
PyDict_SetItemString(d, "error", SunAudioError);
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize sunaudiodev module");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ initsv()
|
||||||
m = Py_InitModule("sv", sv_methods);
|
m = Py_InitModule("sv", sv_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
SvError = PyString_FromString("sv.error");
|
SvError = PyErr_NewException("sv.error", NULL, NULL);
|
||||||
if (SvError == NULL || PyDict_SetItemString(d, "error", SvError) != 0)
|
if (SvError == NULL || PyDict_SetItemString(d, "error", SvError) != 0)
|
||||||
Py_FatalError("can't define sv.error");
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,9 +241,6 @@ PyInit_termios()
|
||||||
m = Py_InitModule("termios", termios_methods);
|
m = Py_InitModule("termios", termios_methods);
|
||||||
|
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
TermiosError = Py_BuildValue("s", "termios.error");
|
TermiosError = PyErr_NewException("termios.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", TermiosError);
|
PyDict_SetItemString(d, "error", TermiosError);
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module termios");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,13 +356,9 @@ initthread()
|
||||||
|
|
||||||
/* Add a symbolic constant */
|
/* Add a symbolic constant */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ThreadError = PyString_FromString("thread.error");
|
ThreadError = PyErr_NewException("thread.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", ThreadError);
|
PyDict_SetItemString(d, "error", ThreadError);
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module thread");
|
|
||||||
|
|
||||||
/* Initialize the C thread library */
|
/* Initialize the C thread library */
|
||||||
init_thread();
|
init_thread();
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,10 +231,6 @@ initxx()
|
||||||
|
|
||||||
/* Add some symbolic constants to the module */
|
/* Add some symbolic constants to the module */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ErrorObject = PyString_FromString("xx.error");
|
ErrorObject = PyErr_NewException("xx.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", ErrorObject);
|
PyDict_SetItemString(d, "error", ErrorObject);
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module xx");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -801,7 +801,7 @@ PyInit_zlib()
|
||||||
zlib_module_documentation,
|
zlib_module_documentation,
|
||||||
(PyObject*)NULL,PYTHON_API_VERSION);
|
(PyObject*)NULL,PYTHON_API_VERSION);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ZlibError = Py_BuildValue("s", "zlib.error");
|
ZlibError = PyErr_NewException("zlib.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", ZlibError);
|
PyDict_SetItemString(d, "error", ZlibError);
|
||||||
|
|
||||||
insint(d, "MAX_WBITS", MAX_WBITS);
|
insint(d, "MAX_WBITS", MAX_WBITS);
|
||||||
|
@ -815,7 +815,4 @@ PyInit_zlib()
|
||||||
insint(d, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
|
insint(d, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
|
||||||
ver = PyString_FromString(ZLIB_VERSION);
|
ver = PyString_FromString(ZLIB_VERSION);
|
||||||
PyDict_SetItemString(d, "ZLIB_VERSION", ver);
|
PyDict_SetItemString(d, "ZLIB_VERSION", ver);
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
Py_FatalError("can't initialize module zlib");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue