Comment 5 for bug 290254

Revision history for this message
Tres Seaver (tseaver) wrote : Re: [Bug 290254] Re: Zope 2.11.1 DateTime - strftime uses current date/time

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tres Seaver wrote:
> I can't reproduce with this test. Note that I verified that dt.__dict__
> matches the one in the 2.9 'datum' above.
>
> def test_strftime_old_instance(self):
> # https://bugs.launchpad.net/zope2/+bug/290254
> # Ensure that dates without _micros attribute (e.g., from old
> # pickles) still render correctly in strftime.
> ISO = '2001-10-10T00:00:00+02:00'
> dt = DateTime(ISO)
> dt._millis = dt._micros / 1000
> del dt._micros
> self.assertEqual(dt.strftime('%Y'), '2001')

I have a version of the test which actually emulates the ZODB load. The
bad news is that it passes as well::

    def test_strftime_old_instance(self):
        # https://bugs.launchpad.net/zope2/+bug/290254
        # Ensure that dates without _micros attribute (e.g., from old
        # pickles) still render correctly in strftime.
        ISO = '2001-10-10T00:00:00+02:00'
        dt = DateTime(ISO)
        dt._millis = dt._micros / 1000
        del dt._micros
        self.assertEqual(dt.strftime('%Y'), '2001')

        # Now, create one via pickling / unpickling.
        from cStringIO import StringIO
        buf = StringIO()

        from cPickle import Pickler
        pickler = Pickler(buf, 1)
        state = pickler.dump(dt)
        buf.seek(0)

        from cPickle import Unpickler
        unpickler = Unpickler(buf)
        dt1 = unpickler.load()

        self.assertEqual(dt.strftime('%Y'), '2001')

- --
===================================================================
Tres Seaver +1 540-429-0999 <email address hidden>
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJrqjY+gerLs4ltQ4RAsr9AJ93uWSco00gxfczMQ2oG16pGrlx/QCdH7Gp
1PdjtFrlLNIKRlJHXzcAg9c=
=5cEt
-----END PGP SIGNATURE-----