Skip to content

Commit e7daca7

Browse files
committed
Replace rfc822 imports with email package (issue2550870)
The rfc822 package has been deprecated since Python v2.3 in favour of the email package.
1 parent 9a1414c commit e7daca7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

roundup/cgi/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
__docformat__ = 'restructuredtext'
44

55
import base64, binascii, cgi, codecs, mimetypes, os
6-
import quopri, random, re, rfc822, stat, sys, time
6+
import quopri, random, re, stat, sys, time
77
import socket, errno
8+
import email.utils
89
from traceback import format_exc
910

1011
try:
@@ -495,7 +496,8 @@ def inner_main(self):
495496
# date = time.time() - 1
496497
#else:
497498
# date = time.time() + 5
498-
self.additional_headers['Expires'] = rfc822.formatdate(date)
499+
self.additional_headers['Expires'] = \
500+
email.utils.formatdate(date, usegmt=True)
499501

500502
# render the content
501503
self.write_html(self.renderContext())
@@ -1074,7 +1076,7 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
10741076

10751077
# spit out headers
10761078
self.additional_headers['Content-Type'] = mime_type
1077-
self.additional_headers['Last-Modified'] = rfc822.formatdate(lmt)
1079+
self.additional_headers['Last-Modified'] = email.utils.formatdate(lmt)
10781080

10791081
ims = None
10801082
# see if there's an if-modified-since...
@@ -1085,7 +1087,7 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
10851087
# cgi will put the header in the env var
10861088
ims = self.env['HTTP_IF_MODIFIED_SINCE']
10871089
if ims:
1088-
ims = rfc822.parsedate(ims)[:6]
1090+
ims = email.utils.parsedate(ims)[:6]
10891091
lmtt = time.gmtime(lmt)[:6]
10901092
if lmtt <= ims:
10911093
raise NotModified

roundup/mailgw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class node. Any parts of other types are each stored in separate files
8080

8181
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
8282
import time, random, sys, logging
83-
import traceback, rfc822
83+
import traceback
84+
import email.utils
8485

8586
from anypy.email_ import decode_header
8687

@@ -147,7 +148,7 @@ def getparam(str, param):
147148
if '=' in f:
148149
i = f.index('=')
149150
if f[:i].strip().lower() == param:
150-
return rfc822.unquote(f[i+1:].strip())
151+
return email.utils.unquote(f[i+1:].strip())
151152
return None
152153

153154
def gpgh_key_getall(key, attr):

0 commit comments

Comments
 (0)