Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Incorrect psycopg2.tz.FixedOffsetTimezone after pickling datetimes with different timezones

#135

Submitted by: Robert Saint

>>> before_pickling = []
>>> cur.execute("SET TIME ZONE 'Europe/Rome';")  # UTC + 1 hour
>>> cur.execute("SELECT '2010-01-01 10:30:45'::timestamptz;")
>>> before_pickling.append(cur.fetchone()[0])
>>> cur.execute("SET TIME ZONE 'Europe/Moscow';")  # UTC + 3 hour
>>> cur.execute("SELECT '2010-01-01 10:30:45'::timestamptz;")
>>> before_pickling.append(cur.fetchone()[0])
>>> print before_pickling
[datetime.datetime(2010, 1, 1, 10, 30, 45, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=60, name=None)), 
    datetime.datetime(2010, 1, 1, 10, 30, 45, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=180, name=None))]
>>> after_pickling = pickle.loads(pickle.dumps(before_pickling))
>>> print before_pickling == after_pickling
False
>>> print after_pickling
[datetime.datetime(2010, 1, 1, 10, 30, 45, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=180, name=None)), 
    datetime.datetime(2010, 1, 1, 10, 30, 45, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=180, name=None))]

Reported by Psycopg website · October 21st, 2012 @ 06:44 PM

State: resolved
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to open
    • Tag cleared.

    What the... Confirmed.

    October 21st, 2012 @ 07:38 PM

  2. Daniele Varrazzo
    Daniele Varrazzo

    Minimal test:

    In [1]: import psycopg2.tz
    
    In [2]: import pickle
    
    In [3]: pickle.loads(pickle.dumps([psycopg2.tz.FixedOffsetTimezone(offset=60), 
        psycopg2.tz.FixedOffsetTimezone(offset=180)]))
    Out[3]: 
    [psycopg2.tz.FixedOffsetTimezone(offset=180, name=None),
     psycopg2.tz.FixedOffsetTimezone(offset=180, name=None)]
    

    October 21st, 2012 @ 07:46 PM

  3. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from open to resolved

    Fixed in my devel and 2.4 maint branch

    October 21st, 2012 @ 09:06 PM