mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Got rid of the errorstr dictionary, which is redundant now that
there's os.strerror() -- also, it would form a locale liability.
This commit is contained in:
parent
4a1f39a26b
commit
851e7d5159
1 changed files with 9 additions and 21 deletions
|
@ -54,57 +54,45 @@ static PyMethodDef errno_methods[] = {
|
||||||
/* Helper function doing the dictionary inserting */
|
/* Helper function doing the dictionary inserting */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inscode(d, e, c, name, code, comment)
|
_inscode(d, de, name, code)
|
||||||
PyObject * d;
|
PyObject *d;
|
||||||
PyObject * e;
|
PyObject *de;
|
||||||
PyObject * c;
|
|
||||||
char *name;
|
char *name;
|
||||||
int code;
|
int code;
|
||||||
char * comment;
|
|
||||||
{
|
{
|
||||||
PyObject *u;
|
PyObject *u;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
PyObject *w;
|
|
||||||
|
|
||||||
#ifdef HAVE_STRERROR
|
|
||||||
if (strerror(code) != NULL)
|
|
||||||
comment = strerror(code);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u = PyString_FromString(name);
|
u = PyString_FromString(name);
|
||||||
v = PyInt_FromLong((long) code);
|
v = PyInt_FromLong((long) code);
|
||||||
w = PyString_FromString(comment);
|
|
||||||
|
|
||||||
if (!u || !v || !w) {
|
if (!u || !v) {
|
||||||
/* Don't bother reporting this error */
|
/* Don't bother reporting this error */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* insert in modules dict */
|
/* insert in modules dict */
|
||||||
PyDict_SetItem(d, u, v);
|
PyDict_SetItem(d, u, v);
|
||||||
/* insert in errorstr dict */
|
|
||||||
PyDict_SetItem(e, v, w);
|
|
||||||
/* insert in errorcode dict */
|
/* insert in errorcode dict */
|
||||||
PyDict_SetItem(c, v, u);
|
PyDict_SetItem(de, v, u);
|
||||||
}
|
}
|
||||||
Py_XDECREF(u);
|
Py_XDECREF(u);
|
||||||
Py_XDECREF(v);
|
Py_XDECREF(v);
|
||||||
Py_XDECREF(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initerrno()
|
initerrno()
|
||||||
{
|
{
|
||||||
PyObject *m, *d, *ds, *de;
|
PyObject *m, *d, *de;
|
||||||
m = Py_InitModule("errno", errno_methods);
|
m = Py_InitModule("errno", errno_methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ds = PyDict_New();
|
|
||||||
if (ds == NULL || PyDict_SetItemString(d,"errorstr",ds))
|
|
||||||
Py_FatalError("can't initialize errno module");
|
|
||||||
de = PyDict_New();
|
de = PyDict_New();
|
||||||
if (de == NULL || PyDict_SetItemString(d,"errorcode",de))
|
if (de == NULL || PyDict_SetItemString(d,"errorcode",de))
|
||||||
Py_FatalError("can't initialize errno module");
|
Py_FatalError("can't initialize errno module");
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The names and comments are borrowed from linux/include/errno.h,
|
* The names and comments are borrowed from linux/include/errno.h,
|
||||||
* which should be pretty all-inclusive
|
* which should be pretty all-inclusive
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue