Patch by Humberto Diogenes for issue 2849, removing rfc822 module from
the standard library. There are still a few cases of it in Demo and Tools, but that's fine for now. These should eventually get cleaned up. mimetools still has an import of rfc822, but mimetools itself should go away.
This commit is contained in:
parent
a5b41eb1e6
commit
596097e0bc
25
Lib/cgi.py
25
Lib/cgi.py
|
@ -32,13 +32,12 @@ __version__ = "2.6"
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
from io import StringIO
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import urllib
|
import urllib
|
||||||
import mimetools
|
import mimetools
|
||||||
import rfc822
|
import email.parser
|
||||||
import collections
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
__all__ = ["MiniFieldStorage", "FieldStorage",
|
__all__ = ["MiniFieldStorage", "FieldStorage",
|
||||||
"parse", "parse_qs", "parse_qsl", "parse_multipart",
|
"parse", "parse_qs", "parse_qsl", "parse_multipart",
|
||||||
|
@ -404,7 +403,7 @@ 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 email.message.Message or a
|
||||||
subclass thereof) containing *all* headers
|
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
|
||||||
|
@ -633,13 +632,17 @@ class FieldStorage:
|
||||||
raise ValueError('Invalid boundary in multipart form: %r' % (ib,))
|
raise ValueError('Invalid boundary in multipart form: %r' % (ib,))
|
||||||
self.list = []
|
self.list = []
|
||||||
klass = self.FieldStorageClass or self.__class__
|
klass = self.FieldStorageClass or self.__class__
|
||||||
part = klass(self.fp, {}, ib,
|
parser = email.parser.FeedParser()
|
||||||
environ, keep_blank_values, strict_parsing)
|
# Create bogus content-type header for proper multipart parsing
|
||||||
# Throw first part away
|
parser.feed('Content-Type: %s; boundary=%s\r\n\r\n' % (self.type, ib))
|
||||||
while not part.done:
|
parser.feed(self.fp.read())
|
||||||
headers = rfc822.Message(self.fp)
|
full_msg = parser.close()
|
||||||
part = klass(self.fp, headers, ib,
|
# Get subparts
|
||||||
environ, keep_blank_values, strict_parsing)
|
msgs = full_msg.get_payload()
|
||||||
|
for msg in msgs:
|
||||||
|
fp = StringIO(msg.get_payload())
|
||||||
|
part = klass(fp, msg, ib, environ, keep_blank_values,
|
||||||
|
strict_parsing)
|
||||||
self.list.append(part)
|
self.list.append(part)
|
||||||
self.skip_lines()
|
self.skip_lines()
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ Content-Disposition: form-data; name="submit"
|
||||||
self.assertEquals(len(fs.list), 4)
|
self.assertEquals(len(fs.list), 4)
|
||||||
expect = [{'name':'id', 'filename':None, 'value':'1234'},
|
expect = [{'name':'id', 'filename':None, 'value':'1234'},
|
||||||
{'name':'title', 'filename':None, 'value':''},
|
{'name':'title', 'filename':None, 'value':''},
|
||||||
{'name':'file', 'filename':'test.txt','value':'Testing 123.\n'},
|
{'name':'file', 'filename':'test.txt', 'value':'Testing 123.'},
|
||||||
{'name':'submit', 'filename':None, 'value':' Add '}]
|
{'name':'submit', 'filename':None, 'value':' Add '}]
|
||||||
for x in range(len(fs.list)):
|
for x in range(len(fs.list)):
|
||||||
for k, exp in expect[x].items():
|
for k, exp in expect[x].items():
|
||||||
|
|
Loading…
Reference in New Issue