summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-11-08 21:54:18 (GMT)
committerYury Selivanov <yury@magic.io>2016-11-08 21:54:18 (GMT)
commit1a9d687a496ff81db0f6bde1437b0a2dcdd5dba7 (patch)
tree65364fcc8d5fec56440b5cb6e8d2ac5377a65427
parent4678b2f44876774b29720913657bb6c65e77e259 (diff)
downloadcpython-1a9d687a496ff81db0f6bde1437b0a2dcdd5dba7.zip
cpython-1a9d687a496ff81db0f6bde1437b0a2dcdd5dba7.tar.gz
cpython-1a9d687a496ff81db0f6bde1437b0a2dcdd5dba7.tar.bz2
Issue #26182: Fix ia refleak in code that raises DeprecationWarning.
-rw-r--r--Misc/NEWS2
-rw-r--r--Python/ast.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 7a4fa3a..361e608 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,8 @@ Core and Builtins
should result in PendingDeprecationWarning in 3.5 and in
DeprecationWarning in 3.6.
+- Issue #26182: Fix ia refleak in code that raises DeprecationWarning.
+
Library
-------
diff --git a/Python/ast.c b/Python/ast.c
index fcd1563..bfae6ed 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -944,17 +944,19 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
PyObject *message = PyUnicode_FromString(
"'async' and 'await' will become reserved keywords"
" in Python 3.7");
+ int ret;
if (message == NULL) {
return 1;
}
- if (PyErr_WarnExplicitObject(
+ ret = PyErr_WarnExplicitObject(
PyExc_DeprecationWarning,
message,
c->c_filename,
LINENO(n),
NULL,
- NULL) < 0)
- {
+ NULL);
+ Py_DECREF(message);
+ if (ret < 0) {
return 1;
}
}