mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +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
|
@ -102,7 +102,7 @@ as a string. :class:`HeaderParser` has the same API as the :class:`Parser`
|
||||||
class.
|
class.
|
||||||
|
|
||||||
|
|
||||||
.. class:: Parser(_class=email.message.Message, strict=None)
|
.. class:: Parser(_class=email.message.Message)
|
||||||
|
|
||||||
The constructor for the :class:`Parser` class takes an optional argument
|
The constructor for the :class:`Parser` class takes an optional argument
|
||||||
*_class*. This must be a callable factory (such as a function or a class), and
|
*_class*. This must be a callable factory (such as a function or a class), and
|
||||||
|
@ -110,13 +110,8 @@ class.
|
||||||
:class:`~email.message.Message` (see :mod:`email.message`). The factory will
|
:class:`~email.message.Message` (see :mod:`email.message`). The factory will
|
||||||
be called without arguments.
|
be called without arguments.
|
||||||
|
|
||||||
The optional *strict* flag is ignored.
|
.. versionchanged:: 3.2
|
||||||
|
Removed the *strict* argument that was deprecated in 2.4.
|
||||||
.. deprecated:: 2.4
|
|
||||||
Because the :class:`Parser` class is a backward compatible API wrapper
|
|
||||||
around the new-in-Python 2.4 :class:`FeedParser`, *all* parsing is
|
|
||||||
effectively non-strict. You should simply stop passing a *strict* flag to
|
|
||||||
the :class:`Parser` constructor.
|
|
||||||
|
|
||||||
The other public :class:`Parser` methods are:
|
The other public :class:`Parser` methods are:
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from email.message import Message
|
||||||
|
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
def __init__(self, *args, **kws):
|
def __init__(self, _class=Message):
|
||||||
"""Parser of RFC 2822 and MIME email messages.
|
"""Parser of RFC 2822 and MIME email messages.
|
||||||
|
|
||||||
Creates an in-memory object tree representing the email message, which
|
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
|
must be created. This class must have a constructor that can take
|
||||||
zero arguments. Default is Message.Message.
|
zero arguments. Default is Message.Message.
|
||||||
"""
|
"""
|
||||||
if len(args) >= 1:
|
self._class = _class
|
||||||
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')
|
|
||||||
|
|
||||||
def parse(self, fp, headersonly=False):
|
def parse(self, fp, headersonly=False):
|
||||||
"""Create a message structure from the data in a file.
|
"""Create a message structure from the data in a file.
|
||||||
|
|
|
@ -87,6 +87,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Removed the 'strict' argument to email.parser.Parser, which has been
|
||||||
|
deprecated since Python 2.4.
|
||||||
|
|
||||||
- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
|
- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
|
||||||
arguments.
|
arguments.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue