def test_pickling(self):
args = 12, 34, 56
orig = timedelta(*args)
- state = orig.__getstate__()
- self.assertEqual(args, state)
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
def test_pickling(self):
args = 6, 7, 23
orig = self.theclass(*args)
- state = orig.__getstate__()
- self.assertEqual(state, ('\x00\x06\x07\x17',), self.theclass)
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
def test_pickling(self):
args = 6, 7, 23, 20, 59, 1, 64**2
orig = self.theclass(*args)
- state = orig.__getstate__()
- self.assertEqual(state, ('\x00\x06\x07\x17\x14\x3b\x01\x00\x10\x00',))
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
def test_pickling(self):
args = 20, 59, 16, 64**2
orig = self.theclass(*args)
- state = orig.__getstate__()
- self.assertEqual(state, ('\x14\x3b\x10\x00\x10\x00',))
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
# Try one without a tzinfo.
args = 20, 59, 16, 64**2
orig = self.theclass(*args)
- state = orig.__getstate__()
- self.assertEqual(state, ('\x14\x3b\x10\x00\x10\x00',))
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
# Try one without a tzinfo.
args = 6, 7, 23, 20, 59, 1, 64**2
orig = self.theclass(*args)
- state = orig.__getstate__()
- self.assertEqual(state, ('\x00\x06\x07\x17\x14\x3b\x01\x00\x10\x00',))
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
/* Pickle support, a simple use of __reduce__. */
+/* __getstate__ isn't exposed */
static PyObject *
delta_getstate(PyDateTime_Delta *self)
{
};
static PyMethodDef delta_methods[] = {
- {"__getstate__", (PyCFunction)delta_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
-
{"__reduce__", (PyCFunction)delta_reduce, METH_NOARGS,
PyDoc_STR("__reduce__() -> (cls, state)")},
/* Pickle support, a simple use of __reduce__. */
+/* __getstate__ isn't exposed */
static PyObject *
date_getstate(PyDateTime_Date *self)
{
{"replace", (PyCFunction)date_replace, METH_KEYWORDS,
PyDoc_STR("Return date with new specified fields.")},
- {"__getstate__", (PyCFunction)date_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
-
{"__reduce__", (PyCFunction)date_reduce, METH_NOARGS,
PyDoc_STR("__reduce__() -> (cls, state)")},
/* Let basestate be the non-tzinfo data string.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
+ * __getstate__ isn't exposed.
*/
static PyObject *
time_getstate(PyDateTime_Time *self)
{"replace", (PyCFunction)time_replace, METH_KEYWORDS,
PyDoc_STR("Return time with new specified fields.")},
- {"__getstate__", (PyCFunction)time_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
-
{"__reduce__", (PyCFunction)time_reduce, METH_NOARGS,
PyDoc_STR("__reduce__() -> (cls, state)")},
/* Let basestate be the non-tzinfo data string.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
+ * __getstate__ isn't exposed.
*/
static PyObject *
datetime_getstate(PyDateTime_DateTime *self)
{"astimezone", (PyCFunction)datetime_astimezone, METH_KEYWORDS,
PyDoc_STR("tz -> convert to local time in new timezone tz\n")},
- {"__getstate__", (PyCFunction)datetime_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
-
{"__reduce__", (PyCFunction)datetime_reduce, METH_NOARGS,
PyDoc_STR("__reduce__() -> (cls, state)")},
if (PyType_Ready(&PyDateTime_TZInfoType) < 0)
return;
- /* Make __getnewargs__ a true alias for __getstate__ */
- {
- PyObject *d, *f;
-
- d = PyDateTime_DateType.tp_dict;
- f = PyDict_GetItemString(d, "__getstate__");
- if (f != NULL) {
- if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- return;
- }
-
- d = PyDateTime_DateTimeType.tp_dict;
- f = PyDict_GetItemString(d, "__getstate__");
- if (f != NULL) {
- if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- return;
- }
-
- d = PyDateTime_DeltaType.tp_dict;
- f = PyDict_GetItemString(d, "__getstate__");
- if (f != NULL) {
- if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- return;
- }
-
- d = PyDateTime_TimeType.tp_dict;
- f = PyDict_GetItemString(d, "__getstate__");
- if (f != NULL) {
- if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- return;
- }
-
- d = PyDateTime_TZInfoType.tp_dict;
- f = PyDict_GetItemString(d, "__getstate__");
- if (f != NULL) {
- if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- return;
- }
- }
-
/* timedelta values */
d = PyDateTime_DeltaType.tp_dict;