Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86cc82e

Browse files
committed
Remove the 'strict' argument to Parser, deprecated since 2.4.
1 parent 1ebdd71 commit 86cc82e

3 files changed

Lines changed: 8 additions & 30 deletions

File tree

Doc/library/email.parser.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,16 @@ as a string. :class:`HeaderParser` has the same API as the :class:`Parser`
102102
class.
103103

104104

105-
.. class:: Parser(_class=email.message.Message, strict=None)
105+
.. class:: Parser(_class=email.message.Message)
106106

107107
The constructor for the :class:`Parser` class takes an optional argument
108108
*_class*. This must be a callable factory (such as a function or a class), and
109109
it is used whenever a sub-message object needs to be created. It defaults to
110110
:class:`~email.message.Message` (see :mod:`email.message`). The factory will
111111
be called without arguments.
112112

113-
The optional *strict* flag is ignored.
114-
115-
.. deprecated:: 2.4
116-
Because the :class:`Parser` class is a backward compatible API wrapper
117-
around the new-in-Python 2.4 :class:`FeedParser`, *all* parsing is
118-
effectively non-strict. You should simply stop passing a *strict* flag to
119-
the :class:`Parser` constructor.
113+
.. versionchanged:: 3.2
114+
Removed the *strict* argument that was deprecated in 2.4.
120115

121116
The other public :class:`Parser` methods are:
122117

Lib/email/parser.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
class Parser:
18-
def __init__(self, *args, **kws):
18+
def __init__(self, _class=Message):
1919
"""Parser of RFC 2822 and MIME email messages.
2020
2121
Creates an in-memory object tree representing the email message, which
@@ -31,27 +31,7 @@ def __init__(self, *args, **kws):
3131
must be created. This class must have a constructor that can take
3232
zero arguments. Default is Message.Message.
3333
"""
34-
if len(args) >= 1:
35-
if '_class' in kws:
36-
raise TypeError("Multiple values for keyword arg '_class'")
37-
kws['_class'] = args[0]
38-
if len(args) == 2:
39-
if 'strict' in kws:
40-
raise TypeError("Multiple values for keyword arg 'strict'")
41-
kws['strict'] = args[1]
42-
if len(args) > 2:
43-
raise TypeError('Too many arguments')
44-
if '_class' in kws:
45-
self._class = kws['_class']
46-
del kws['_class']
47-
else:
48-
self._class = Message
49-
if 'strict' in kws:
50-
warnings.warn("'strict' argument is deprecated (and ignored)",
51-
DeprecationWarning, 2)
52-
del kws['strict']
53-
if kws:
54-
raise TypeError('Unexpected keyword arguments')
34+
self._class = _class
5535

5636
def parse(self, fp, headersonly=False):
5737
"""Create a message structure from the data in a file.

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ Core and Builtins
8787
Library
8888
-------
8989

90+
- Removed the 'strict' argument to email.parser.Parser, which has been
91+
deprecated since Python 2.4.
92+
9093
- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
9194
arguments.
9295

0 commit comments

Comments
 (0)