Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
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
20 changes: 13 additions & 7 deletions 20 Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ create_filter(PyObject *category, PyObject *action_str, const char *modname)
}

/* This assumes the line number is zero for now. */
PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
category, modname_obj, _PyLong_GetZero());
PyObject *items[] = {action_str, Py_None, category, modname_obj,
_PyLong_GetZero()};
PyObject *filter = PyTuple_FromArray(items, 5);
Py_DECREF(modname_obj);
return filter;
}
Expand Down Expand Up @@ -631,10 +632,14 @@ update_registry(PyInterpreterState *interp, PyObject *registry, PyObject *text,
PyObject *altkey;
int rc;

if (add_zero)
altkey = PyTuple_Pack(3, text, category, _PyLong_GetZero());
else
altkey = PyTuple_Pack(2, text, category);
if (add_zero) {
PyObject *items[] = {text, category, _PyLong_GetZero()};
altkey = PyTuple_FromArray(items, 3);
}
else {
PyObject *items[] = {text, category};
altkey = PyTuple_FromArray(items, 2);
}

rc = already_warned(interp, registry, altkey, 1);
Py_XDECREF(altkey);
Expand Down Expand Up @@ -815,7 +820,8 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message,
}

/* Create key. */
key = PyTuple_Pack(3, text, category, lineno_obj);
PyObject *key_items[] = {text, category, lineno_obj};
key = PyTuple_FromArray(key_items, 3);
if (key == NULL)
goto cleanup;

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.