[Python-checkins] cpython (merge 3.3 -> default): merge 3.3 (#17328)

benjamin.peterson python-checkins at python.org
Mon Mar 4 15:48:40 CET 2013


http://hg.python.org/cpython/rev/fac46cf6af3f
changeset:   82477:fac46cf6af3f
parent:      82474:5c8a5cfe25b0
parent:      82476:1a589001d752
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Mar 04 09:48:30 2013 -0500
summary:
  merge 3.3 (#17328)

files:
  Misc/NEWS            |  2 ++
  Objects/dictobject.c |  4 ++--
  2 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,8 @@
 - Issue #17032: The "global" in the "NameError: global name 'x' is not defined"
   error message has been removed.  Patch by Ram Rachum.
 
+- Issue #17328: Fix possible refleak in dict.setdefault.
+
 - Issue #17223: array module: Fix a crasher when converting an array containing
   invalid characters (outside range [U+0000; U+10ffff]) to Unicode:
   repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2235,14 +2235,14 @@
         return NULL;
     val = *value_addr;
     if (val == NULL) {
-        Py_INCREF(failobj);
-        Py_INCREF(key);
         if (mp->ma_keys->dk_usable <= 0) {
             /* Need to resize. */
             if (insertion_resize(mp) < 0)
                 return NULL;
             ep = find_empty_slot(mp, key, hash, &value_addr);
         }
+        Py_INCREF(failobj);
+        Py_INCREF(key);
         MAINTAIN_TRACKING(mp, key, failobj);
         ep->me_key = key;
         ep->me_hash = hash;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list