mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Remove the 'strict' argument to Parser, deprecated since 2.4.
This commit is contained in:
parent
1ebdd714ac
commit
86cc82e36f
3 changed files with 8 additions and 30 deletions
|
@ -15,7 +15,7 @@ from email.message import Message
|
|||
|
||||
|
||||
class Parser:
|
||||
def __init__(self, *args, **kws):
|
||||
def __init__(self, _class=Message):
|
||||
"""Parser of RFC 2822 and MIME email messages.
|
||||
|
||||
Creates an in-memory object tree representing the email message, which
|
||||
|
@ -31,27 +31,7 @@ class Parser:
|
|||
must be created. This class must have a constructor that can take
|
||||
zero arguments. Default is Message.Message.
|
||||
"""
|
||||
if len(args) >= 1:
|
||||
if '_class' in kws:
|
||||
raise TypeError("Multiple values for keyword arg '_class'")
|
||||
kws['_class'] = args[0]
|
||||
if len(args) == 2:
|
||||
if 'strict' in kws:
|
||||
raise TypeError("Multiple values for keyword arg 'strict'")
|
||||
kws['strict'] = args[1]
|
||||
if len(args) > 2:
|
||||
raise TypeError('Too many arguments')
|
||||
if '_class' in kws:
|
||||
self._class = kws['_class']
|
||||
del kws['_class']
|
||||
else:
|
||||
self._class = Message
|
||||
if 'strict' in kws:
|
||||
warnings.warn("'strict' argument is deprecated (and ignored)",
|
||||
DeprecationWarning, 2)
|
||||
del kws['strict']
|
||||
if kws:
|
||||
raise TypeError('Unexpected keyword arguments')
|
||||
self._class = _class
|
||||
|
||||
def parse(self, fp, headersonly=False):
|
||||
"""Create a message structure from the data in a file.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue