[Python-Dev] Re: [Python-checkins] python/nondist/sandbox/datetime obj_delta.c,1.14,1.15 test_both.py,1.15,1.16

Michael Hudson mwh@python.net
02 Dec 2002 17:38:54 +0000


tim_one@users.sourceforge.net writes:

> + /* XXX A further broken attempt to get pickling to work.
> +  * XXX This avoids the problem above, but dies instead with
> +  * XXX    PicklingError: Can't pickle <type 'timedelta'>: it's not
> +  * XXX    found as __builtin__.tmedelta

You need to arrange for a module name to appear in timedelta's
tp_name:

Index: obj_delta.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_delta.c,v
retrieving revision 1.15
diff -c -r1.15 obj_delta.c
*** obj_delta.c 2 Dec 2002 17:31:21 -0000       1.15
--- obj_delta.c 2 Dec 2002 17:37:55 -0000
***************
*** 673,679 ****
  static PyTypeObject PyDateTime_DeltaType = {
        PyObject_HEAD_INIT(NULL)
        0,                                              /* ob_size */
!       "timedelta",                                    /* tp_name */
        sizeof(PyDateTime_Delta),                       /* tp_basicsize */
        0,                                              /* tp_itemsize */
        0,                                              /* tp_dealloc */
--- 673,679 ----
  static PyTypeObject PyDateTime_DeltaType = {
        PyObject_HEAD_INIT(NULL)
        0,                                              /* ob_size */
!       "datetime.timedelta",                           /* tp_name */
        sizeof(PyDateTime_Delta),                       /* tp_basicsize */
        0,                                              /* tp_itemsize */
        0,                                              /* tp_dealloc */

seems a good bet.

Cheers,
M.

-- 
  I'm not sure that the ability to create routing diagrams 
  similar to pretzels with mad cow disease is actually a 
  marketable skill.                                     -- Steve Levin
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html