On Dec 16, 2005, at 4:20 PM, Benji York wrote:
Gary zope/i18n/format.py:141 and 149

Yup: the pytz StaticTzInfo is being used in a non-API way, and while pickling works, unpickling doesn't (ew!).

Here's the interactive prompt example, if anyone cares.

>>> import pytz.tzinfo
>>> tz = pytz.tzinfo.StaticTzInfo()
>>> import pickle
>>> import datetime
>>> delta = datetime.timedelta(hours=-5)
>>> delta
datetime.timedelta(-1, 68400)
>>> tz._utcoffset = delta
>>> pickle.dumps(tz)
>>> pickle.loads(pickle.dumps(tz))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
File "/home/gary/z4i/var/opt/python/lib/python2.4/pickle.py", line 1394, in loads
    return Unpickler(file).load()
File "/home/gary/z4i/var/opt/python/lib/python2.4/pickle.py", line 872, in load
File "/home/gary/z4i/var/opt/python/lib/python2.4/pickle.py", line 1153, in load_reduce
    value = func(*args)
File "/home/gary/z4i/var/src/zope3/src/pytz/__init__.py", line 163, in _p
    return unpickler(*args)
File "/home/gary/z4i/var/src/zope3/src/pytz/tzinfo.py", line 340, in unpickler tz = pytz.timezone(zone) File "/home/gary/z4i/var/src/zope3/src/pytz/__init__.py", line 47, in timezone zone = _munge_zone(zone) File "/home/gary/z4i/var/src/zope3/src/pytz/__init__.py", line 71, in _munge_zone
    return zone.replace('+', '_plus_').replace('-', '_minus_')
AttributeError: 'NoneType' object has no attribute 'replace'

This is not pytz's fault: it wasn't designed to work the way that the format module is using it, as Stuart points out following Philipp's 'XXX'.

I think I can fix it by using the pytz.reference.FixedOffset class. That's what I'll try to do now.


Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to