Skip to content

bpo-1635741: Port errno module to multiphase initialization #19923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-1635741: Update
  • Loading branch information
corona10 committed May 6, 2020
commit 2b241ca23f81b7e5f9e452ffcdc6b7d9a25974cc
45 changes: 19 additions & 26 deletions Modules/errnomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,33 @@ static PyMethodDef errno_methods[] = {
/* Helper function doing the dictionary inserting */

static int
_add_errcode(PyObject *d, PyObject *de, const char *name, int code)
_add_errcode(PyObject *module_dict, PyObject *error_dict, const char *name_str, int code_int)
{
PyObject *u = PyUnicode_FromString(name);
if (!u) {
PyObject *name = PyUnicode_FromString(name_str);
if (!name) {
return -1;
}

PyObject *v = PyLong_FromLong((long) code);
if (!v) {
Py_DECREF(u);
PyObject *code = PyLong_FromLong(code_int);
if (!code) {
Py_DECREF(name);
return -1;
}

/* 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 */
if (PyDict_SetItem(d, u, v) < 0) {
Py_DECREF(u);
Py_DECREF(v);
return -1;
}
/* insert in errorcode dict */
if (PyDict_SetItem(de, v, u) < 0) {
Py_DECREF(u);
Py_DECREF(v);
return -1;
}
int ret = -1;
/* insert in modules dict */
if (PyDict_SetItem(module_dict, name, code) < 0) {
goto end;
}
Py_DECREF(u);
Py_DECREF(v);
return 0;
/* insert in errorcode dict */
if (PyDict_SetItem(error_dict, code, name) < 0) {
goto end;
}
ret = 0;
end:
Py_DECREF(name);
Py_DECREF(code);
return ret;
}

static int
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy