From 1526582df686a66e15c1944aed13c2ea6b922882 Mon Sep 17 00:00:00 2001
From: Christian Heimes <christian@cheimes.de>
Date: Wed, 12 Sep 2012 17:52:46 +0200
Subject: Partly revert ad3824a90261 and add comment about reference ownership

---
 Python/symtable.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Python/symtable.c b/Python/symtable.c
index 00b3427..992b5ae 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -37,7 +37,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
     if (ste == NULL)
         goto fail;
     ste->ste_table = st;
-    ste->ste_id = k;
+    ste->ste_id = k; /* ste owns reference to k */
 
     ste->ste_name = name;
     Py_INCREF(name);
@@ -83,7 +83,6 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
 
     return ste;
  fail:
-    Py_XDECREF(k);
     Py_XDECREF(ste);
     return NULL;
 }
-- 
cgit v0.12


From 55ad6515c90148bbcaeee0d7a185bfecc9aa1693 Mon Sep 17 00:00:00 2001
From: Christian Heimes <christian@cheimes.de>
Date: Wed, 12 Sep 2012 17:58:10 +0200
Subject: Cleanup 'k' when the creation of PySTEntryObject fails. ad3824a90261
 used to decref 'k' in too many error cases.

---
 Python/symtable.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Python/symtable.c b/Python/symtable.c
index 992b5ae..35fc6e1 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -34,8 +34,10 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
     if (k == NULL)
         goto fail;
     ste = PyObject_New(PySTEntryObject, &PySTEntry_Type);
-    if (ste == NULL)
+    if (ste == NULL) {
+        Py_DECREF(k);
         goto fail;
+    }
     ste->ste_table = st;
     ste->ste_id = k; /* ste owns reference to k */
 
-- 
cgit v0.12

