#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

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

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