Hi everyone, this is my first post to this list. I am trying to create a subclass of datetime.date and pickle it, but I get errors on loading it back. I have created a VERY simple demo of this:
import datetime class MyDate(datetime.date): """ This should be pickleable. >>> md = MyDate(2007, 1, 6) >>> import pickle >>> pickle.dump(md, open("test.pickle", 'w')) >>> mdp = pickle.load(open("test.pickle")) >>> import os; os.remove("test.pickle") """ def __init__(self, y, m, d): datetime.date.__init__(self, y, m, d) if __name__ == "__main__": import doctest doctest.testmod() The traceback that occurs is: Traceback (most recent call last): File "C:\Python25\lib\doctest.py", line 1212, in __run compileflags, 1) in test.globs File "<doctest __main__.MyDate[3]>", line 1, in <module> mdp = pickle.load(open("test.pickle")) File "C:\Python25\lib\pickle.py", line 1370, in load return Unpickler(file).load() File "C:\Python25\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python25\lib\pickle.py", line 1133, in load_red value = func(*args) TypeError: __init__() takes exactly 4 arguments (2 given) I have found a few relating issues: - https://sourceforge.net/tracker/?func=detail&atid=105470&aid=952807&group_id=5470 - http://sourceforge.net/tracker/index.php?func=detail&aid=720908&group_id=5470&atid=105470 But these are both rather old and are marked as fixed. I am running Python 2.5.1 on Windows XP SP2. Any help here would be greatly appreciated! - Mike -- http://mail.python.org/mailman/listinfo/python-list