summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-01-05 17:17:09 (GMT)
committerFred Drake <fdrake@acm.org>2002-01-05 17:17:09 (GMT)
commitdb519205a2cd89eb43d7622bc3b37b8b8ea8a629 (patch)
tree833950ce8cd8cd5af98fa959565452edec7fb561 /Lib
parent1e2fb57b5f978421b54578f0931ab1e64db1dbba (diff)
downloadcpython-db519205a2cd89eb43d7622bc3b37b8b8ea8a629.zip
cpython-db519205a2cd89eb43d7622bc3b37b8b8ea8a629.tar.gz
cpython-db519205a2cd89eb43d7622bc3b37b8b8ea8a629.tar.bz2
Time2Internaldate(): Call isinstance() once for each of the type tests
instead of possibly twice by using a sequence of types to check for. Add a message to the ValueError that can be raised.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/imaplib.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index ed785ed..04d4d87 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -1069,14 +1069,14 @@ def Time2Internaldate(date_time):
Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'
"""
- if isinstance(date_time, int) or isinstance(date_time, float):
+ if isinstance(date_time, (int, float)):
tt = time.localtime(date_time)
- elif isinstance(date_time, tuple) or \
- isinstance(date_time, time.struct_time):
+ elif isinstance(date_time, (tuple, time.struct_time)):
tt = date_time
elif isinstance(date_time, str):
return date_time # Assume in correct format
- else: raise ValueError
+ else:
+ raise ValueError("date_time not of a known type")
dt = time.strftime("%d-%b-%Y %H:%M:%S", tt)
if dt[0] == '0':