[Python-checkins] python/dist/src/Objects typeobject.c,2.204,2.205
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Mon, 10 Feb 2003 13:31:31 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv25780/Objects
Modified Files:
typeobject.c
Log Message:
Get rid of the "bozo" __getstate__ that was inserted when __slots__
was used. This simplifies some logic in copy_reg.py (used by
pickling). It also broke a test, but this was rewritten to test the
new feature. :-)
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.204
retrieving revision 2.205
diff -C2 -d -r2.204 -r2.205
*** typeobject.c 6 Feb 2003 15:22:49 -0000 2.204
--- typeobject.c 10 Feb 2003 21:31:27 -0000 2.205
***************
*** 1469,1487 ****
};
- /* bozo: __getstate__ that raises TypeError */
-
- static PyObject *
- bozo_func(PyObject *self, PyObject *args)
- {
- PyErr_SetString(PyExc_TypeError,
- "a class that defines __slots__ without "
- "defining __getstate__ cannot be pickled");
- return NULL;
- }
-
- static PyMethodDef bozo_ml = {"__getstate__", bozo_func, METH_VARARGS};
-
- static PyObject *bozo_obj = NULL;
-
static int
valid_identifier(PyObject *s)
--- 1469,1472 ----
***************
*** 1740,1760 ****
Py_DECREF(slots);
slots = newslots;
-
- /* See if *this* class defines __getstate__ */
- if (PyDict_GetItemString(dict, "__getstate__") == NULL) {
- /* If not, provide a bozo that raises TypeError */
- if (bozo_obj == NULL) {
- bozo_obj = PyCFunction_New(&bozo_ml, NULL);
- if (bozo_obj == NULL)
- goto bad_slots;
- }
- if (PyDict_SetItemString(dict,
- "__getstate__",
- bozo_obj) < 0)
- {
- Py_DECREF(bozo_obj);
- goto bad_slots;
- }
- }
/* Secondary bases may provide weakrefs or dict */
--- 1725,1728 ----