Patch #1079734: remove dependencies on (deprecated) rfc822 and mimetools

modules, replacing with email. Thanks to Josh Hoyt for the patch!
This commit is contained in:
Johannes Gijsbers 2005-01-08 13:56:36 +00:00
parent a3beee185c
commit c7fc10a418
1 changed files with 9 additions and 7 deletions

View File

@ -38,8 +38,7 @@ from operator import attrgetter
import sys import sys
import os import os
import urllib import urllib
import mimetools import email.Parser
import rfc822
import UserDict import UserDict
try: try:
from cStringIO import StringIO from cStringIO import StringIO
@ -108,6 +107,8 @@ log = initlog # The current logging function
# Parsing functions # Parsing functions
# ================= # =================
_header_parser = email.Parser.HeaderParser()
# Maximum input we will accept when REQUEST_METHOD is POST # Maximum input we will accept when REQUEST_METHOD is POST
# 0 ==> unlimited input # 0 ==> unlimited input
maxlen = 0 maxlen = 0
@ -237,7 +238,7 @@ def parse_multipart(fp, pdict):
Arguments: Arguments:
fp : input file fp : input file
pdict: dictionary containing other parameters of conten-type header pdict: dictionary containing other parameters of content-type header
Returns a dictionary just like parse_qs(): keys are the field names, each Returns a dictionary just like parse_qs(): keys are the field names, each
value is a list of values for that field. This is easy to use but not 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):
data = None data = None
if terminator: if terminator:
# At start of next part. Read headers first. # At start of next part. Read headers first.
headers = mimetools.Message(fp) headers = _header_parser.parse(fp)
clength = headers.getheader('content-length') clength = headers.getheader('content-length')
if clength: if clength:
try: try:
@ -407,8 +408,9 @@ class FieldStorage:
disposition_options: dictionary of corresponding options disposition_options: dictionary of corresponding options
headers: a dictionary(-like) object (sometimes rfc822.Message or a headers: a dictionary(-like) object (sometimes
subclass thereof) containing *all* headers email.Message.Message or a subclass thereof) containing *all*
headers
The class is subclassable, mostly for the purpose of overriding The class is subclassable, mostly for the purpose of overriding
the make_file() method, which is called internally to come up with the make_file() method, which is called internally to come up with
@ -650,7 +652,7 @@ class FieldStorage:
environ, keep_blank_values, strict_parsing) environ, keep_blank_values, strict_parsing)
# Throw first part away # Throw first part away
while not part.done: while not part.done:
headers = rfc822.Message(self.fp) headers = _header_parser.parse(self.fp)
part = klass(self.fp, headers, ib, part = klass(self.fp, headers, ib,
environ, keep_blank_values, strict_parsing) environ, keep_blank_values, strict_parsing)
self.list.append(part) self.list.append(part)