This project is archived and is in readonly mode.

#135 ✓resolved
Psycopg website

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

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

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))]

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

Pages