Skip to content

Commit f2e03be

Browse files
author
jlgijsbers
committed
Patch #1079734: remove dependencies on (deprecated) rfc822 and mimetools
modules, replacing with email. Thanks to Josh Hoyt for the patch! git-svn-id: http://svn.python.org/projects/python/trunk@38238 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 18425e7 commit f2e03be

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Lib/cgi.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
import sys
3939
import os
4040
import urllib
41-
import mimetools
42-
import rfc822
41+
import email.Parser
4342
import UserDict
4443
try:
4544
from cStringIO import StringIO
@@ -108,6 +107,8 @@ def nolog(*allargs):
108107
# Parsing functions
109108
# =================
110109

110+
_header_parser = email.Parser.HeaderParser()
111+
111112
# Maximum input we will accept when REQUEST_METHOD is POST
112113
# 0 ==> unlimited input
113114
maxlen = 0
@@ -237,7 +238,7 @@ def parse_multipart(fp, pdict):
237238
238239
Arguments:
239240
fp : input file
240-
pdict: dictionary containing other parameters of conten-type header
241+
pdict: dictionary containing other parameters of content-type header
241242
242243
Returns a dictionary just like parse_qs(): keys are the field names, each
243244
value is a list of values for that field. This is easy to use but not
@@ -270,7 +271,7 @@ def parse_multipart(fp, pdict):
270271
data = None
271272
if terminator:
272273
# At start of next part. Read headers first.
273-
headers = mimetools.Message(fp)
274+
headers = _header_parser.parse(fp)
274275
clength = headers.getheader('content-length')
275276
if clength:
276277
try:
@@ -407,8 +408,9 @@ class FieldStorage:
407408
408409
disposition_options: dictionary of corresponding options
409410
410-
headers: a dictionary(-like) object (sometimes rfc822.Message or a
411-
subclass thereof) containing *all* headers
411+
headers: a dictionary(-like) object (sometimes
412+
email.Message.Message or a subclass thereof) containing *all*
413+
headers
412414
413415
The class is subclassable, mostly for the purpose of overriding
414416
the make_file() method, which is called internally to come up with
@@ -650,7 +652,7 @@ def read_multi(self, environ, keep_blank_values, strict_parsing):
650652
environ, keep_blank_values, strict_parsing)
651653
# Throw first part away
652654
while not part.done:
653-
headers = rfc822.Message(self.fp)
655+
headers = _header_parser.parse(self.fp)
654656
part = klass(self.fp, headers, ib,
655657
environ, keep_blank_values, strict_parsing)
656658
self.list.append(part)

0 commit comments

Comments
 (0)