summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-08-18 12:27:40 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-08-18 12:27:40 (GMT)
commit318a12eb0129bd75754cb3cc68076cc3b737074f (patch)
treee9c1f7d303365669f6e636c5bd0550eb909a0e52 /Lib/logging
parentfe84d17a6a3e255191f664c5609a061a9bb70c60 (diff)
downloadcpython-318a12eb0129bd75754cb3cc68076cc3b737074f.zip
cpython-318a12eb0129bd75754cb3cc68076cc3b737074f.tar.gz
cpython-318a12eb0129bd75754cb3cc68076cc3b737074f.tar.bz2
Patch #791776: Replace SMTPHandler.date_time with email.Utils.formatdate.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/handlers.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index d9de952..2cb1fb0 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -654,21 +654,6 @@ class SMTPHandler(logging.Handler):
"""
return self.subject
- weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
-
- monthname = [None,
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
-
- def date_time(self):
- """Return the current date and time formatted for a MIME header."""
- year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time())
- s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
- self.weekdayname[wd],
- day, self.monthname[month], year,
- hh, mm, ss)
- return s
-
def emit(self, record):
"""
Emit a record.
@@ -677,6 +662,7 @@ class SMTPHandler(logging.Handler):
"""
try:
import smtplib
+ from email.Utils import formatdate
port = self.mailport
if not port:
port = smtplib.SMTP_PORT
@@ -686,7 +672,7 @@ class SMTPHandler(logging.Handler):
self.fromaddr,
string.join(self.toaddrs, ","),
self.getSubject(record),
- self.date_time(), msg)
+ formatdate(), msg)
smtp.sendmail(self.fromaddr, self.toaddrs, msg)
smtp.quit()
except: