]> granicus.if.org Git - python/commitdiff
Issue8757: Implicit set-to-frozenset conversion not thread-safe.
authorRaymond Hettinger <python@rcn.com>
Fri, 6 Aug 2010 09:57:49 +0000 (09:57 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 6 Aug 2010 09:57:49 +0000 (09:57 +0000)
Misc/NEWS
Objects/setobject.c

index 84ce9c842326d86b30cb45556273951562f632f0..f8e4fa8c4b34362586e7b0497405c41cf28559e4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.1.3?
 Core and Builtins
 -----------------
 
+- Issue #83755:  Implicit set-to-frozenset conversion was not thread-safe.
+
 - Issue #9416: Fix some issues with complex formatting where the
   output with no type specifier failed to match the str output:
 
index f0e1fcbeedbe5a5f15471a72bf720748488fba34..e7966bb28bb5d8105f17cb22f96506d5916dfb66 100644 (file)
@@ -1846,12 +1846,10 @@ set_contains(PySetObject *so, PyObject *key)
         if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
             return -1;
         PyErr_Clear();
-        tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
+        tmpkey = make_new_set(&PyFrozenSet_Type, key);
         if (tmpkey == NULL)
             return -1;
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         rv = set_contains(so, tmpkey);
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         Py_DECREF(tmpkey);
     }
     return rv;
@@ -1881,12 +1879,10 @@ set_remove(PySetObject *so, PyObject *key)
         if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
             return NULL;
         PyErr_Clear();
-        tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
+        tmpkey = make_new_set(&PyFrozenSet_Type, key);
         if (tmpkey == NULL)
             return NULL;
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         rv = set_discard_key(so, tmpkey);
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         Py_DECREF(tmpkey);
         if (rv == -1)
             return NULL;
@@ -1915,12 +1911,10 @@ set_discard(PySetObject *so, PyObject *key)
         if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
             return NULL;
         PyErr_Clear();
-        tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
+        tmpkey = make_new_set(&PyFrozenSet_Type, key);
         if (tmpkey == NULL)
             return NULL;
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         result = set_discard(so, tmpkey);
-        set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
         Py_DECREF(tmpkey);
         return result;
     }