From 58bb82e7b4b50fa5efaefc1196bd927992fbe783 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sun, 1 Apr 2012 16:05:46 +0200 Subject: Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch by Suman Saha. --- Misc/NEWS | 3 +++ Objects/bytearrayobject.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 32c0b9e..4bf3a91 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2.4 Core and Builtins ----------------- +- Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch + by Suman Saha. + - Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as the module name that was not interned. diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 4202ff2..55b4df6 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2234,8 +2234,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg) } bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size); - if (bytearray_obj == NULL) + if (bytearray_obj == NULL) { + Py_DECREF(it); return NULL; + } buf = PyByteArray_AS_STRING(bytearray_obj); while ((item = PyIter_Next(it)) != NULL) { @@ -2268,8 +2270,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg) return NULL; } - if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) + if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) { + Py_DECREF(bytearray_obj); return NULL; + } Py_DECREF(bytearray_obj); Py_RETURN_NONE; -- cgit v0.12 From 0261d754cd7f6bedf7415d94b18b7b631bfa8a63 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sun, 1 Apr 2012 17:40:17 +0300 Subject: Removing the test of Element that causes ref-leak in GC (issue #14464). I will now continue investigating the cause of the ref-leak, but I wanted to remove the test so that the refcount test in the buildbots could be clean. The whole change (adding GC to Element) is not reverted because it improved the situation (GC works for immediate cycles) and didn't cause regressions (the test is new and was added together with the fix). --- Lib/test/test_xml_etree.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index bd2a826..aa9a40d 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1859,16 +1859,6 @@ class BasicElementTest(unittest.TestCase): gc_collect() self.assertIsNone(wref()) - # A longer cycle: d->e->e2->d - e = ET.Element('joe') - d = Dummy() - d.dummyref = e - wref = weakref.ref(d) - e2 = ET.SubElement(e, 'foo', attr=d) - del d, e, e2 - gc_collect() - self.assertIsNone(wref()) - class ElementTreeTest(unittest.TestCase): def test_istype(self): -- cgit v0.12 From 709176f10c1774f608a318171a94371e7d05d98f Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sun, 1 Apr 2012 17:19:09 +0200 Subject: Issue #14151: Raise a ValueError, not a NameError, when trying to create a multiprocessing Client or Listener with an AF_PIPE type address under non-Windows platforms. Patch by Popa Claudiu. --- Lib/multiprocessing/connection.py | 9 +++++++++ Lib/test/test_multiprocessing.py | 14 +++++++++++++- Misc/NEWS | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index df00f1d..fa6f7b3 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -94,6 +94,13 @@ def arbitrary_address(family): else: raise ValueError('unrecognized family') +def _validate_family(family): + ''' + Checks if the family is valid for the current environment. + ''' + if sys.platform != 'win32' and family == 'AF_PIPE': + raise ValueError('Family %s is not recognized.' % family) + def address_type(address): ''' @@ -126,6 +133,7 @@ class Listener(object): or default_family address = address or arbitrary_address(family) + _validate_family(family) if family == 'AF_PIPE': self._listener = PipeListener(address, backlog) else: @@ -163,6 +171,7 @@ def Client(address, family=None, authkey=None): Returns a connection to the address of a `Listener` ''' family = family or address_type(address) + _validate_family(family) if family == 'AF_PIPE': c = PipeClient(address) else: diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 8edb420..8de7a8d 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2319,8 +2319,20 @@ class TestStdinBadfiledescriptor(unittest.TestCase): flike.flush() assert sio.getvalue() == 'foo' + +# +# Issue 14151: Test invalid family on invalid environment +# + +class TestInvalidFamily(unittest.TestCase): + + @unittest.skipIf(WIN32, "skipped on Windows") + def test_invalid_family(self): + with self.assertRaises(ValueError): + multiprocessing.connection.Listener(r'\\.\test') + testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, - TestStdinBadfiledescriptor] + TestStdinBadfiledescriptor, TestInvalidFamily] # # diff --git a/Misc/NEWS b/Misc/NEWS index 4bf3a91..2fa911e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,10 @@ Core and Builtins Library ------- +- Issue #14151: Raise a ValueError, not a NameError, when trying to create + a multiprocessing Client or Listener with an AF_PIPE type address under + non-Windows platforms. Patch by Popa Claudiu. + - Issue #13872: socket.detach() now marks the socket closed (as mirrored in the socket repr()). Patch by Matt Joiner. -- cgit v0.12 From ffc3e1ab40e3474b4cfff0d2a798d7a674579e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 1 Apr 2012 19:54:33 +0200 Subject: Add MASM define to PGI and PGO builds --- PCbuild/_decimal.vcproj | 1486 +++++++++++++++++++++++------------------------ 1 file changed, 743 insertions(+), 743 deletions(-) diff --git a/PCbuild/_decimal.vcproj b/PCbuild/_decimal.vcproj index 1d047c2..8cbe626 100644 --- a/PCbuild/_decimal.vcproj +++ b/PCbuild/_decimal.vcproj @@ -1,743 +1,743 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v0.12 From 8dbbae990c28c31f54d26f2e50c2155fd9e9b084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 1 Apr 2012 19:55:48 +0200 Subject: Add _decimal and _testbuffer modules. --- Tools/msi/msi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py index a18debc..38f3443 100644 --- a/Tools/msi/msi.py +++ b/Tools/msi/msi.py @@ -97,7 +97,9 @@ extensions = [ '_sqlite3.pyd', '_hashlib.pyd', '_multiprocessing.pyd', - '_lzma.pyd' + '_lzma.pyd', + '_decimal.pyd', + '_testbuffer.pyd' ] # Well-known component UUIDs -- cgit v0.12 From 41e031004bd156ea579a35d8e1d74cafe8dac3e0 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Sun, 1 Apr 2012 23:25:34 +0200 Subject: Fix Overflow exception in the bignum factorial benchmark that is due to the recent change of the default value for context.Emax. --- Modules/_decimal/tests/bench.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/_decimal/tests/bench.py b/Modules/_decimal/tests/bench.py index 013f0f6..ea0823a 100644 --- a/Modules/_decimal/tests/bench.py +++ b/Modules/_decimal/tests/bench.py @@ -84,7 +84,10 @@ print("\n# ===================================================================== print("# Factorial") print("# ======================================================================\n") -C.getcontext().prec = C.MAX_PREC +c = C.getcontext() +c.prec = C.MAX_PREC +c.Emax = C.MAX_EMAX +c.Emin = C.MIN_EMIN for n in [100000, 1000000]: -- cgit v0.12 From ab3c1c1994ec819781ba27ba8a5c6d75f70cb2af Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 1 Apr 2012 18:48:02 -0400 Subject: be consistent with rest of function --- Objects/typeobject.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f0c787f..9f0ab15 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -475,9 +475,8 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context) new_base = best_base(value); - if (!new_base) { + if (!new_base) return -1; - } if (!compatible_for_assignment(type->tp_base, new_base, "__bases__")) return -1; -- cgit v0.12 From 3471bb67e7add5c809c00e5c0977047017548b40 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 1 Apr 2012 18:48:40 -0400 Subject: remove extraneous condition --- Objects/typeobject.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9f0ab15..c12cd7c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -464,12 +464,10 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context) type->tp_name, Py_TYPE(ob)->tp_name); return -1; } - if (PyType_Check(ob)) { - if (PyType_IsSubtype((PyTypeObject*)ob, type)) { - PyErr_SetString(PyExc_TypeError, - "a __bases__ item causes an inheritance cycle"); - return -1; - } + if (PyType_IsSubtype((PyTypeObject*)ob, type)) { + PyErr_SetString(PyExc_TypeError, + "a __bases__ item causes an inheritance cycle"); + return -1; } } -- cgit v0.12 From b6af60c2a9e2625987bcdd6775eb9fe8834c9641 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 1 Apr 2012 18:49:54 -0400 Subject: adjust formatting --- Objects/typeobject.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c12cd7c..8cfa889 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -458,11 +458,11 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context) for (i = 0; i < PyTuple_GET_SIZE(value); i++) { ob = PyTuple_GET_ITEM(value, i); if (!PyType_Check(ob)) { - PyErr_Format( - PyExc_TypeError, - "%s.__bases__ must be tuple of old- or new-style classes, not '%s'", - type->tp_name, Py_TYPE(ob)->tp_name); - return -1; + PyErr_Format(PyExc_TypeError, + "%s.__bases__ must be tuple of old- or " + "new-style classes, not '%s'", + type->tp_name, Py_TYPE(ob)->tp_name); + return -1; } if (PyType_IsSubtype((PyTypeObject*)ob, type)) { PyErr_SetString(PyExc_TypeError, -- cgit v0.12