This project is archived and is in readonly mode.
Incorrect psycopg2.tz.FixedOffsetTimezone after pickling datetimes with different timezones
Reported by Psycopg website | 2012-10-21 18:44:58 UTC
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
-

Daniele Varrazzo 2012-10-21 19:38:09 UTC
- State changed from new to open
- Tag cleared.
What the... Confirmed.
-

Daniele Varrazzo 2012-10-21 19:46:04 UTC
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)] -

Daniele Varrazzo 2012-10-21 21:06:39 UTC
- State changed from open to resolved
Fixed in my devel and 2.4 maint branch
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
WARNING: the informations in this tracker are archived. Please submit new tickets or comments to the new tracker.
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.