summaryrefslogtreecommitdiffstats
path: root/Lib/html
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-11-02 15:08:24 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-11-02 15:08:24 (GMT)
commit88ebfb129b59dc8a2b855fc93fcf32457128d64d (patch)
treec1c3e6ab03e4c6431330402cabe40b8889353454 /Lib/html
parent28f0beaff692117a55ab919e87d336044935a0ab (diff)
downloadcpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.zip
cpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.tar.gz
cpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.tar.bz2
#15114: The html.parser module now raises a DeprecationWarning when the strict argument of HTMLParser or the HTMLParser.error method are used.
Diffstat (limited to 'Lib/html')
-rw-r--r--Lib/html/parser.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/html/parser.py b/Lib/html/parser.py
index 18f3115..d7541ae 100644
--- a/Lib/html/parser.py
+++ b/Lib/html/parser.py
@@ -94,6 +94,8 @@ class HTMLParseError(Exception):
return result
+_strict_sentinel = object()
+
class HTMLParser(_markupbase.ParserBase):
"""Find tags and other markup and call handler functions.
@@ -116,16 +118,18 @@ class HTMLParser(_markupbase.ParserBase):
CDATA_CONTENT_ELEMENTS = ("script", "style")
- def __init__(self, strict=False):
+ def __init__(self, strict=_strict_sentinel):
"""Initialize and reset this instance.
If strict is set to False (the default) the parser will parse invalid
markup, otherwise it will raise an error. Note that the strict mode
- is deprecated.
+ and argument are deprecated.
"""
- if strict:
- warnings.warn("The strict mode is deprecated.",
+ if strict is not _strict_sentinel:
+ warnings.warn("The strict argument and mode are deprecated.",
DeprecationWarning, stacklevel=2)
+ else:
+ strict = False # default
self.strict = strict
self.reset()
@@ -151,6 +155,8 @@ class HTMLParser(_markupbase.ParserBase):
self.goahead(1)
def error(self, message):
+ warnings.warn("The 'error' method is deprecated.",
+ DeprecationWarning, stacklevel=2)
raise HTMLParseError(message, self.getpos())
__starttag_text = None