@@ -94,6 +94,8 @@ def __str__(self):
9494 return result
9595
9696
97+ _strict_sentinel = object ()
98+
9799class HTMLParser (_markupbase .ParserBase ):
98100 """Find tags and other markup and call handler functions.
99101
@@ -116,16 +118,18 @@ class HTMLParser(_markupbase.ParserBase):
116118
117119 CDATA_CONTENT_ELEMENTS = ("script" , "style" )
118120
119- def __init__ (self , strict = False ):
121+ def __init__ (self , strict = _strict_sentinel ):
120122 """Initialize and reset this instance.
121123
122124 If strict is set to False (the default) the parser will parse invalid
123125 markup, otherwise it will raise an error. Note that the strict mode
124- is deprecated.
126+ and argument are deprecated.
125127 """
126- if strict :
127- warnings .warn ("The strict mode is deprecated." ,
128+ if strict is not _strict_sentinel :
129+ warnings .warn ("The strict argument and mode are deprecated." ,
128130 DeprecationWarning , stacklevel = 2 )
131+ else :
132+ strict = False # default
129133 self .strict = strict
130134 self .reset ()
131135
@@ -151,6 +155,8 @@ def close(self):
151155 self .goahead (1 )
152156
153157 def error (self , message ):
158+ warnings .warn ("The 'error' method is deprecated." ,
159+ DeprecationWarning , stacklevel = 2 )
154160 raise HTMLParseError (message , self .getpos ())
155161
156162 __starttag_text = None
0 commit comments