We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import datetime import pickle import time import pytz from freezegun import freeze_time class Foo: def __init__(self): self.now = datetime.datetime.fromtimestamp(time.time()) def __reduce__(self): # https://docs.python.org/3/library/pickle.html#object.__reduce__ return self.now.__reduce__() with freeze_time(): dt = datetime.datetime.fromtimestamp(time.time(), tz=pytz.utc) print(repr(dt)) dt = datetime.datetime.fromtimestamp(time.time()) print(repr(dt)) pickle.dumps(Foo())
Results in
FakeDatetime(2024, 3, 14, 21, 12, 0, 615787, tzinfo=<UTC>) datetime.datetime(2024, 3, 14, 21, 12, 0, 615787) Traceback (most recent call last): File "FILE", line 25, in <module> pickle.dumps(Foo()) _pickle.PicklingError: Can't pickle <class 'datetime.datetime'>: it's not the same object as datetime.datetime
This sample shows two related issues:
freezegun/freezegun/api.py
Line 377 in 12e54da
I think this case should be addressed by #475
The text was updated successfully, but these errors were encountered:
Hi @jogo! #475 does indeed fix this, as far as I can tell.
That PR is merged now, so I'll close this one. Thank you for raising this!
Sorry, something went wrong.
No branches or pull requests
Results in
This sample shows two related issues:
freezegun/freezegun/api.py
Line 377 in 12e54da
I think this case should be addressed by #475
The text was updated successfully, but these errors were encountered: