[Zope3-checkins] CVS: Zope3/lib/python/datetime - _datetime.py:1.13
Tim Peters
tim.one@comcast.net
Sat, 21 Dec 2002 12:42:33 -0500
Update of /cvs-repository/Zope3/lib/python/datetime
In directory cvs.zope.org:/tmp/cvs-serv17133/lib/python/datetime
Modified Files:
_datetime.py
Log Message:
Always catch non-string results from indirect tzinfo.dst() calls.
=== Zope3/lib/python/datetime/_datetime.py 1.12 => 1.13 ===
--- Zope3/lib/python/datetime/_datetime.py:1.12 Sat Dec 21 12:21:15 2002
+++ Zope3/lib/python/datetime/_datetime.py Sat Dec 21 12:42:02 2002
@@ -220,13 +220,18 @@
def _check_utc_offset(name, offset):
if offset is None:
return
- if not isinstance(offset, (int, long)):
- raise TypeError("%s() must return None, int or long, not %s" %
- (name, type(offset)))
+ if not isinstance(offset, (int, long, timedelta)):
+ raise TypeError("tzinfo.%s() must return None, integer "
+ "or timedelta, not '%s'" % (name, type(offset)))
if -1440 < offset < 1440:
return
raise ValueError("%s()=%d, must be in -1439..1439" % (name, offset))
+def _check_tzname(name):
+ if name is not None and not isinstance(name, str):
+ raise TypeError("tzinfo.tzname() must return None or string, "
+ "not '%s'" % type(name))
+
# This is a start at a struct tm workalike. Goals:
#
# + Works the same way across platforms.
@@ -1080,6 +1085,7 @@
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
"""
name = _call_tzinfo_method(self, self.__tzinfo, "tzname")
+ _check_tzname(name)
return name
def dst(self):
@@ -1483,6 +1489,7 @@
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
"""
name = _call_tzinfo_method(self, self.__tzinfo, "tzname")
+ _check_tzname(name)
return name
def dst(self):