diff options
author | Guido van Rossum <guido@python.org> | 1995-06-22 18:56:36 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-06-22 18:56:36 (GMT) |
commit | efe5ac404f12781a1a13f7d433139a819fa0c1f4 (patch) | |
tree | bd61dc63cea1ef75b6332e3d5f75178dec6f5f48 /Lib | |
parent | b47281539afdcd4b38a59ff4c5f80897ceb1fd02 (diff) | |
download | cpython-efe5ac404f12781a1a13f7d433139a819fa0c1f4.zip cpython-efe5ac404f12781a1a13f7d433139a819fa0c1f4.tar.gz cpython-efe5ac404f12781a1a13f7d433139a819fa0c1f4.tar.bz2 |
make reporting unbalanced tags an overridable method
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sgmllib.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 17e5745..2c92c31 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -226,8 +226,8 @@ class SGMLParser: if self.stack and self.stack[-1] == tag: del self.stack[-1] else: - print '*** Unbalanced </' + tag + '>' - print '*** Stack:', self.stack + self.report_unbalanced(tag) + # Now repair it found = None for i in range(len(self.stack)): if self.stack[i] == tag: found = i @@ -235,6 +235,11 @@ class SGMLParser: del self.stack[found:] method() + # Example -- report an unbalanced </...> tag. + def report_unbalanced(self, tag): + print '*** Unbalanced </' + tag + '>' + print '*** Stack:', self.stack + # Example -- handle character reference, no need to override def handle_charref(self, name): try: |