Replacing a builtin type is begging for trouble ;-) Try restoring datetime.datetime
to its original value before your program exits. atexit
is run when the program is shutting down (see the docs - it's a standard Python module). Presumably IPython
is using sqlite3
when the program ends to store some history, and your bogus datetime.datetime
class is confusing the heck out of it.
orig_datetime = datetime.datetime # new
datetime.datetime = datetimeMock # the same
try:
# start processing
...
finally:
datetime.datetime = orig_datetime
Or run your program from a vanilla shell, instead of via IPython.