From f7e84e12b3fd591b959ce0bcb1e84361694d685e Mon Sep 17 00:00:00 2001 From: Sjoerd Mullender Date: Wed, 6 Dec 2000 10:37:57 +0000 Subject: [PATCH] Two changes: - Use new Error class (subclass of RuntimeError so is backward compatible) which is raised when RuntimeError used to be raised. - Report original attribute name in error messages instead of name mangled with namespace URL. --- Lib/xmllib.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Lib/xmllib.py b/Lib/xmllib.py index b8422cb4508..2f925563de1 100644 --- a/Lib/xmllib.py +++ b/Lib/xmllib.py @@ -8,6 +8,9 @@ import string version = '0.3' +class Error(RuntimeError): + pass + # Regular expressions used for parsing _S = '[ \t\r\n]+' # white space @@ -309,7 +312,7 @@ class XMLParser: 'encoding', 'standalone') if version[1:-1] != '1.0': - raise RuntimeError, 'only XML version 1.0 supported' + raise Error('only XML version 1.0 supported') if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) @@ -390,7 +393,7 @@ class XMLParser: i = i+1 continue else: - raise RuntimeError, 'neither < nor & ??' + raise Error('neither < nor & ??') # We get here only if incomplete matches but # nothing else break @@ -419,7 +422,7 @@ class XMLParser: def parse_comment(self, i): rawdata = self.rawdata if rawdata[i:i+4] <> '