From 876ff02e6a4b968c97a0efa990a13900bd1d127a Mon Sep 17 00:00:00 2001 From: Will Kahn-Greene Date: Wed, 29 Nov 2017 09:50:54 -0500 Subject: [PATCH] Make ReparseException private ReparseException is used internally and not intended for external use. Fixes #371 --- html5lib/_inputstream.py | 4 ++-- html5lib/constants.py | 2 +- html5lib/html5parser.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py index 79f2331e..c60d1a47 100644 --- a/html5lib/_inputstream.py +++ b/html5lib/_inputstream.py @@ -9,7 +9,7 @@ import webencodings from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase -from .constants import ReparseException +from .constants import _ReparseException from . import _utils from io import StringIO @@ -530,7 +530,7 @@ def changeEncoding(self, newEncoding): self.rawStream.seek(0) self.charEncoding = (newEncoding, "certain") self.reset() - raise ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding)) + raise _ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding)) def detectBOM(self): """Attempts to detect at BOM at the start of the stream. If diff --git a/html5lib/constants.py b/html5lib/constants.py index c0db14f1..1ff80419 100644 --- a/html5lib/constants.py +++ b/html5lib/constants.py @@ -2943,5 +2943,5 @@ class DataLossWarning(UserWarning): pass -class ReparseException(Exception): +class _ReparseException(Exception): pass diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py index dd8ba6f7..75765924 100644 --- a/html5lib/html5parser.py +++ b/html5lib/html5parser.py @@ -20,7 +20,7 @@ adjustForeignAttributes as adjustForeignAttributesMap, adjustMathMLAttributes, adjustSVGAttributes, E, - ReparseException + _ReparseException ) @@ -83,7 +83,7 @@ def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kw try: self.mainLoop() - except ReparseException: + except _ReparseException: self.reset() self.mainLoop()