]> granicus.if.org Git - python/commitdiff
As per further discussion, re-enable the typeobject.c guard for picklability.
authorBarry Warsaw <barry@python.org>
Mon, 11 Jan 2016 20:51:27 +0000 (15:51 -0500)
committerBarry Warsaw <barry@python.org>
Mon, 11 Jan 2016 20:51:27 +0000 (15:51 -0500)
upstreams such as Cython will have to adjust.

1  2 
Misc/NEWS
Objects/typeobject.c

diff --cc Misc/NEWS
index 593ed2475eb4d29ef3b3b5e7112fbfc354e363a3,7bdce713012c00b8274bd8d55cb84f0442925395..e062d918ce3de12f54aafe9eed35a1cbca660085
+++ b/Misc/NEWS
@@@ -10,9 -10,9 +10,6 @@@ Release date: tb
  Core and Builtins
  -----------------
  
--- Issue #22995: [UPDATE] Comment out the one of the pickleability tests in
--  _PyObject_GetState() due to regressions observed in Cython-based projects.
--
  - Issue #25961: Disallowed null characters in the type name.
  
  - Issue #25973: Fix segfault when an invalid nonlocal statement binds a name
index f92f1e9cfea78be2ea03c0bebad20d6e891bef09,415f91689f66a7728a7157ea74d66a3cc791a86f..db15cf67682ccceb8a4b7527c72ccc12df384cff
@@@ -3872,33 -3866,6 +3872,24 @@@ _PyObject_GetState(PyObject *obj, int r
          }
  
          assert(slotnames == Py_None || PyList_Check(slotnames));
- #if 0
-         /* 2016-01-11 barry - This clause breaks at least three packages which
-            rely on Cython: kivy, pysam, and s3ql.  Cython may be doing
-            something funny under the hood, but as this is clearly a regression
-            and the rationale for this prohibition is suspect, I am commenting
-            this out.  Perhaps it should just be removed.  See issue #22995 for
-            details.
-         */
 +        if (required) {
 +            Py_ssize_t basicsize = PyBaseObject_Type.tp_basicsize;
 +            if (obj->ob_type->tp_dictoffset)
 +                basicsize += sizeof(PyObject *);
 +            if (obj->ob_type->tp_weaklistoffset)
 +                basicsize += sizeof(PyObject *);
 +            if (slotnames != Py_None)
 +                basicsize += sizeof(PyObject *) * Py_SIZE(slotnames);
 +            if (obj->ob_type->tp_basicsize > basicsize) {
 +                Py_DECREF(slotnames);
 +                Py_DECREF(state);
 +                PyErr_Format(PyExc_TypeError,
 +                             "can't pickle %.200s objects",
 +                             Py_TYPE(obj)->tp_name);
 +                return NULL;
 +            }
 +        }
- #endif
 +
          if (slotnames != Py_None && Py_SIZE(slotnames) > 0) {
              PyObject *slots;
              Py_ssize_t slotnames_size, i;