From 3f50cdc05e5254e1ce012ceca449387d50d28bc5 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 10 Feb 2003 21:31:27 +0000 Subject: 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. :-) --- Objects/typeobject.c | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'Objects/typeobject.c') diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 01eb7069f1..31ac441a62 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1468,21 +1468,6 @@ static PyGetSetDef subtype_getsets_weakref_only[] = { {0} }; -/* 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) { @@ -1740,23 +1725,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) 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 */ if (nbases > 1 && ((may_add_dict && !add_dict) || -- cgit v1.2.1