mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
[3.14] GH-140590: Fix setstate for functools.partial C-module (GH-140671) (#140698)
Some checks are pending
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / iOS (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / iOS (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
GH-140590: Fix setstate for functools.partial C-module (GH-140671)
(cherry picked from commit d26686a7f8)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
This commit is contained in:
parent
84e01df175
commit
02604314ba
3 changed files with 7 additions and 1 deletions
|
|
@ -406,6 +406,7 @@ class TestPartial:
|
||||||
|
|
||||||
def test_setstate_errors(self):
|
def test_setstate_errors(self):
|
||||||
f = self.partial(signature)
|
f = self.partial(signature)
|
||||||
|
|
||||||
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}))
|
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}))
|
||||||
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, {}, None))
|
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, {}, None))
|
||||||
self.assertRaises(TypeError, f.__setstate__, [capture, (), {}, None])
|
self.assertRaises(TypeError, f.__setstate__, [capture, (), {}, None])
|
||||||
|
|
@ -413,6 +414,8 @@ class TestPartial:
|
||||||
self.assertRaises(TypeError, f.__setstate__, (capture, None, {}, None))
|
self.assertRaises(TypeError, f.__setstate__, (capture, None, {}, None))
|
||||||
self.assertRaises(TypeError, f.__setstate__, (capture, [], {}, None))
|
self.assertRaises(TypeError, f.__setstate__, (capture, [], {}, None))
|
||||||
self.assertRaises(TypeError, f.__setstate__, (capture, (), [], None))
|
self.assertRaises(TypeError, f.__setstate__, (capture, (), [], None))
|
||||||
|
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, ()))
|
||||||
|
self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, 'test'))
|
||||||
|
|
||||||
def test_setstate_subclasses(self):
|
def test_setstate_subclasses(self):
|
||||||
f = self.partial(signature)
|
f = self.partial(signature)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix arguments checking for the :meth:`!functools.partial.__setstate__` that
|
||||||
|
may lead to internal state corruption and crash. Patch by Sergey Miryanov.
|
||||||
|
|
@ -699,7 +699,8 @@ partial_setstate(PyObject *self, PyObject *state)
|
||||||
if (!PyArg_ParseTuple(state, "OOOO", &fn, &fnargs, &kw, &dict) ||
|
if (!PyArg_ParseTuple(state, "OOOO", &fn, &fnargs, &kw, &dict) ||
|
||||||
!PyCallable_Check(fn) ||
|
!PyCallable_Check(fn) ||
|
||||||
!PyTuple_Check(fnargs) ||
|
!PyTuple_Check(fnargs) ||
|
||||||
(kw != Py_None && !PyDict_Check(kw)))
|
(kw != Py_None && !PyDict_Check(kw)) ||
|
||||||
|
(dict != Py_None && !PyDict_Check(dict)))
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_TypeError, "invalid partial state");
|
PyErr_SetString(PyExc_TypeError, "invalid partial state");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue