summaryrefslogtreecommitdiff
path: root/bs4/__init__.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2021-10-24 21:15:31 -0400
committerLeonard Richardson <leonardr@segfault.org>2021-10-24 21:15:31 -0400
commitc1a7aaae7140897b2e845be8c5aa077d6654ee0a (patch)
treedf6a58adc912d111e619094d7884d034a6649249 /bs4/__init__.py
parentdd8aa7237b88569c99e85b300b0cf537aeaebfbd (diff)
Issue a warning when an HTML parser is used to parse a document that
looks like XML but not XHTML. [bug=1939121]
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r--bs4/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py
index 2cdfed5..49e05e7 100644
--- a/bs4/__init__.py
+++ b/bs4/__init__.py
@@ -35,7 +35,11 @@ import warnings
if sys.version_info.major < 3:
raise ImportError('You are trying to use a Python 3-specific version of Beautiful Soup under Python 2. This will not work. The final version of Beautiful Soup to support Python 2 was 4.9.3.')
-from .builder import builder_registry, ParserRejectedMarkup
+from .builder import (
+ builder_registry,
+ ParserRejectedMarkup,
+ XMLParsedAsHTMLWarning,
+)
from .dammit import UnicodeDammit
from .element import (
CData,
@@ -67,7 +71,7 @@ class MarkupResemblesLocatorWarning(UserWarning):
on disk.
"""
-
+
class BeautifulSoup(Tag):
"""A data structure representing a parsed HTML or XML document.
@@ -735,7 +739,7 @@ class BeautifulSoup(Tag):
#print("End tag: " + name)
self.endData()
self._popToTag(name, nsprefix)
-
+
def handle_data(self, data):
"""Called by the tree builder when a chunk of textual data is encountered."""
self.current_data.append(data)