This project is archived and is in readonly mode.
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
-
Daniele Varrazzo October 21st, 2012 @ 07:38 PM
- State changed from new to open
- Tag cleared.
What the... Confirmed.
-
Daniele Varrazzo October 21st, 2012 @ 07:46 PM
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 October 21st, 2012 @ 09:06 PM
- 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 ยป
<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.