summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-30 06:09:41 (GMT)
committerGitHub <noreply@github.com>2017-03-30 06:09:41 (GMT)
commitba85d69a3e3610bdd05f0dd372cf4ebca178c7fb (patch)
treefe0766c34601880610c3399a8f01c35ab6e8fe8e /Python/_warnings.c
parente6911a44f69c0d302db60f49952a9cf69da69a2b (diff)
downloadcpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.zip
cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.gz
cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.bz2
bpo-29878: Add global instances of int for 0 and 1. (#852)
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 67f4c6b..add72e4 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -287,20 +287,15 @@ static int
update_registry(PyObject *registry, PyObject *text, PyObject *category,
int add_zero)
{
- PyObject *altkey, *zero = NULL;
+ PyObject *altkey;
int rc;
- if (add_zero) {
- zero = PyLong_FromLong(0);
- if (zero == NULL)
- return -1;
- altkey = PyTuple_Pack(3, text, category, zero);
- }
+ if (add_zero)
+ altkey = PyTuple_Pack(3, text, category, _PyLong_Zero);
else
altkey = PyTuple_Pack(2, text, category);
rc = already_warned(registry, altkey, 1);
- Py_XDECREF(zero);
Py_XDECREF(altkey);
return rc;
}
@@ -1130,7 +1125,6 @@ create_filter(PyObject *category, const char *action)
static PyObject *default_str = NULL;
static PyObject *always_str = NULL;
PyObject *action_obj = NULL;
- PyObject *lineno, *result;
if (!strcmp(action, "ignore")) {
if (ignore_str == NULL) {
@@ -1169,12 +1163,7 @@ create_filter(PyObject *category, const char *action)
}
/* This assumes the line number is zero for now. */
- lineno = PyLong_FromLong(0);
- if (lineno == NULL)
- return NULL;
- result = PyTuple_Pack(5, action_obj, Py_None, category, Py_None, lineno);
- Py_DECREF(lineno);
- return result;
+ return PyTuple_Pack(5, action_obj, Py_None, category, Py_None, _PyLong_Zero);
}
static PyObject *