Git Product home page Git Product logo

Comments (8)

nickwilliams-eventbrite avatar nickwilliams-eventbrite commented on September 26, 2024 1

I'm sorry for resurfacing this very old issue. Please ignore my stupidity. After extensive debugging, I discovered that an instance of the _freeze_time class was making its way into the dict I was trying to copy. Resolving that fixed my problem. Nothing to see here. Move along.

from freezegun.

spulec avatar spulec commented on September 26, 2024

This was also fixed by 0453e5f

from freezegun.

jtsoi avatar jtsoi commented on September 26, 2024

@spulec , I think this is still an issue, or something changed in later releases...

Failing test:

@freezegun.freeze_time('2001-01-01')
def test_picke_mock_time():
    import cPickle as pickle
    data = {'time': datetime.datetime.utcnow()}
    result = pickle.loads(pickle.dumps(data))
    compare(result, data)

Runs fine without the freezegun decorator, with the decorator, raises:

PicklingError: Can't pickle <type 'datetime.datetime'>: it's not the same object as datetime.datetime

It would be good to have this test as a regression.
I would send a pull-request, but I can't figure why it is broken. Maybe you can find the problem using this test.

from freezegun.

spulec avatar spulec commented on September 26, 2024

Ah, you are correct. It looks like I fixed now(), but not utcnow(). Fixed with 768a60f and added tests. Going to push a new release in a minute.

from freezegun.

spulec avatar spulec commented on September 26, 2024

Also, thanks!

from freezegun.

foxx avatar foxx commented on September 26, 2024

Still happening with cPickle and python-rq.

  File "local/lib/python2.7/site-packages/rq/job.py", line 303, in save
    obj['data'] = dumps(self.job_tuple)
cPickle.PicklingError: Can't pickle <type 'datetime.datetime'>: it's not the same object as datetime.datetime

from freezegun.

spulec avatar spulec commented on September 26, 2024

I believe that's the same issue as #30

from freezegun.

nickwilliams-eventbrite avatar nickwilliams-eventbrite commented on September 26, 2024

Has this regressed in 0.3.x? I'm getting TypeError: can't pickle NotImplementedType objects when trying to copy.deepcopy any object with a faked date/time/datetime in it.

from freezegun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.