Skip to content

Commit 1a9d687

Browse files
committed
Issue python#26182: Fix ia refleak in code that raises DeprecationWarning.
1 parent 4678b2f commit 1a9d687

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Core and Builtins
1818
should result in PendingDeprecationWarning in 3.5 and in
1919
DeprecationWarning in 3.6.
2020

21+
- Issue #26182: Fix ia refleak in code that raises DeprecationWarning.
22+
2123
Library
2224
-------
2325

Python/ast.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,17 +944,19 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
944944
PyObject *message = PyUnicode_FromString(
945945
"'async' and 'await' will become reserved keywords"
946946
" in Python 3.7");
947+
int ret;
947948
if (message == NULL) {
948949
return 1;
949950
}
950-
if (PyErr_WarnExplicitObject(
951+
ret = PyErr_WarnExplicitObject(
951952
PyExc_DeprecationWarning,
952953
message,
953954
c->c_filename,
954955
LINENO(n),
955956
NULL,
956-
NULL) < 0)
957-
{
957+
NULL);
958+
Py_DECREF(message);
959+
if (ret < 0) {
958960
return 1;
959961
}
960962
}

0 commit comments

Comments
 (0)