cpython: 3e3a7d825736 (original) (raw)

Mercurial > cpython

changeset 81989:3e3a7d825736

Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple parses nested mutating sequence. [#6083]

Serhiy Storchaka storchaka@gmail.com
date Mon, 04 Feb 2013 12:57:16 +0200
parents 1791304d05c4(current diff)e0ee10f27e5f(diff)
children e6d6b860a720
files Lib/test/test_functools.py Lib/test/test_resource.py Misc/NEWS
diffstat 7 files changed, 117 insertions(+), 16 deletions(-)[+] [-] Lib/ctypes/test/test_returnfuncptrs.py 28 Lib/test/test_functools.py 22 Lib/test/test_resource.py 17 Misc/NEWS 3 Modules/_ctypes/_ctypes.c 24 Modules/_functoolsmodule.c 6 Modules/resource.c 33

line wrap: on

line diff

--- a/Lib/ctypes/test/test_returnfuncptrs.py +++ b/Lib/ctypes/test/test_returnfuncptrs.py @@ -33,5 +33,33 @@ class ReturnFuncPtrTestCase(unittest.Tes self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0) self.assertRaises(TypeError, strchr, b"abcdef")

+

+

+ if name == "main": unittest.main()

--- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -194,7 +194,25 @@ class TestPartial(object): self.assertEqual(signature(f), signature(f_copy)) class TestPartialC(BaseTestC, TestPartial):

+

+

class TestPartialPy(BaseTestPy, TestPartial): @@ -204,7 +222,7 @@ class TestPartialPy(BaseTestPy, TestPart def test_repr(self): raise unittest.SkipTest("Python implementation of partial uses own repr") -class TestPartialCSubclass(BaseTestC, TestPartial): +class TestPartialCSubclass(TestPartialC): class PartialSubclass(c_functools.partial): pass

--- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -107,6 +107,23 @@ class ResourceTest(unittest.TestCase): except (ValueError, AttributeError): pass

+

+ def test_main(verbose=None): support.run_unittest(ResourceTest)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -235,6 +235,9 @@ Core and Builtins Library ------- +- Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple

--- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3188,23 +3188,37 @@ PyCFuncPtr_FromDll(PyTypeObject *type, P { char name; int ( address)(void);

+

+ obj = PyObject_GetAttrString(dll, "_handle");

#else @@ -3240,9 +3256,12 @@ PyCFuncPtr_FromDll(PyTypeObject *type, P #else PyErr_SetString(PyExc_AttributeError, ctypes_dlerror()); #endif

#endif

@@ -3255,7 +3274,6 @@ PyCFuncPtr_FromDll(PyTypeObject *type, P *(void **)self->b_ptr = address;

--- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -218,10 +218,10 @@ partial_reduce(partialobject *pto, PyObj } static PyObject * -partial_setstate(partialobject *pto, PyObject *args) +partial_setstate(partialobject *pto, PyObject *state) { PyObject *fn, *fnargs, *kw, *dict;

--- a/Modules/resource.c +++ b/Modules/resource.c @@ -142,10 +142,9 @@ resource_setrlimit(PyObject *self, PyObj { struct rlimit rl; int resource;

if (resource < 0 || resource >= RLIM_NLIMITS) { @@ -154,21 +153,34 @@ resource_setrlimit(PyObject *self, PyObj return NULL; }

+

+ #if !defined(HAVE_LARGEFILE_SUPPORT) rl.rlim_cur = PyLong_AsLong(curobj); if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred())

#else /* The limits are probably bigger than a long */ rl.rlim_cur = PyLong_AsLongLong(curobj); if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred())

#endif rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY; @@ -182,10 +194,15 @@ resource_setrlimit(PyObject *self, PyObj "not allowed to raise maximum limit"); else PyErr_SetFromErrno(PyExc_OSError);

} static PyObject *