Scrapy, a fast high-level web crawling & scraping framework for Python.
Deprecate scrapy.python.utils.FixedSGMLParser
Mikhail Korobov2b749668bad6
diff --git a/scrapy/utils/python.py b/scrapy/utils/python.pyindex 566b50f17..db88a4e55 100644--- a/scrapy/utils/python.py+++ b/scrapy/utils/python.py@@ -10,23 +10,40 @@ import reimport inspectimport weakrefimport errno+import warningsfrom functools import partial, wraps-from sgmllib import SGMLParser+import six-class FixedSGMLParser(SGMLParser):- """The SGMLParser that comes with Python has a bug in the convert_charref()- method. This is the same class with the bug fixed"""+from scrapy.exceptions import ScrapyDeprecationWarning- def convert_charref(self, name):- """This method fixes a bug in Python's SGMLParser."""- try:- n = int(name)- except ValueError:- return- if not 0 <= n <= 127 : # ASCII ends at 127, not 255- return- return self.convert_codepoint(n)++if six.PY2:+ from sgmllib import SGMLParser++ class FixedSGMLParser(SGMLParser):+ """The SGMLParser that comes with Python has a bug in the convert_charref()+ method. This is the same class with the bug fixed.++ Warning: this class is deprecated and will be removed in future releases.+ """++ def __init__(self, *args, **kwargs):+ warnings.warn(+ "FixedSGMLParser is deprecated and will be removed in future releases.",+ ScrapyDeprecationWarning+ )+ SGMLParser.__init__(self, *args, **kwargs)++ def convert_charref(self, name):+ """This method fixes a bug in Python's SGMLParser."""+ try:+ n = int(name)+ except ValueError:+ return+ if not 0 <= n <= 127 : # ASCII ends at 127, not 255+ return+ return self.convert_codepoint(n)def flatten(x):