summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2018-09-28 07:17:01 -0500
committerJason Madden <jamadden@gmail.com>2018-09-28 07:17:01 -0500
commitbf468b939411a785dbab5344cfc471369975edd8 (patch)
tree8c1255bc8b357052b0efcdc3d1ecc64583c7f40c
parent2b68d749272cb1fcbe10ad02eab9e9bdb9ff8f0d (diff)
downloadzope-configuration-bf468b939411a785dbab5344cfc471369975edd8.tar.gz
Simplify ZopeSAXParseException.
We don't seem to need to do the reformating it claimed was for emacs.
-rw-r--r--src/zope/configuration/tests/test_xmlconfig.py10
-rw-r--r--src/zope/configuration/xmlconfig.py20
2 files changed, 9 insertions, 21 deletions
diff --git a/src/zope/configuration/tests/test_xmlconfig.py b/src/zope/configuration/tests/test_xmlconfig.py
index 9e19b5a..3cb1270 100644
--- a/src/zope/configuration/tests/test_xmlconfig.py
+++ b/src/zope/configuration/tests/test_xmlconfig.py
@@ -58,16 +58,16 @@ class ZopeSAXParseExceptionTests(unittest.TestCase):
return self._getTargetClass()(*args, **kw)
def test___str___not_a_sax_error(self):
- zxce = self._makeOne(Exception('Not a SAX error'))
+ zxce = self._makeOne("info", Exception('Not a SAX error'))
self.assertEqual(
str(zxce),
- "Not a SAX error\n Exception: Not a SAX error")
+ "info\n Exception: Not a SAX error")
def test___str___w_a_sax_error(self):
- zxce = self._makeOne(Exception('filename.xml:24:32:WAAA'))
+ zxce = self._makeOne("info", Exception('filename.xml:24:32:WAAA'))
self.assertEqual(
str(zxce),
- 'File "filename.xml", line 24.32, WAAA\n Exception: filename.xml:24:32:WAAA')
+ 'info\n Exception: filename.xml:24:32:WAAA')
class ParserInfoTests(unittest.TestCase):
@@ -395,7 +395,7 @@ class Test_processxmlfile(unittest.TestCase):
registerCommonDirectives(context)
with self.assertRaises(ZopeSAXParseException) as exc:
self._callFUT(StringIO(), context)
- self.assertEqual(str(exc.exception._v),
+ self.assertEqual(str(exc.exception.evalue),
'<string>:1:0: no element found')
def test_w_valid_xml_fp(self):
diff --git a/src/zope/configuration/xmlconfig.py b/src/zope/configuration/xmlconfig.py
index 8785c01..b12b091 100644
--- a/src/zope/configuration/xmlconfig.py
+++ b/src/zope/configuration/xmlconfig.py
@@ -90,29 +90,17 @@ class ZopeXMLConfigurationError(ConfigurationWrapperError):
class ZopeSAXParseException(ConfigurationWrapperError):
"""
- Sax Parser errors, reformatted in an emacs friendly way.
+ Sax Parser errors as a ConfigurationError.
Example
>>> from zope.configuration.xmlconfig import ZopeSAXParseException
- >>> v = ZopeSAXParseException(Exception("foo.xml:12:3:Not well formed"))
+ >>> v = ZopeSAXParseException("info", Exception("foo.xml:12:3:Not well formed"))
>>> print(v)
- File "foo.xml", line 12.3, Not well formed
+ info
Exception: foo.xml:12:3:Not well formed
"""
- def __init__(self, exception):
- s = tuple(str(exception).split(':'))
- if len(s) == 4:
- info = 'File "%s", line %s.%s, %s' % s
- else:
- info = str(exception)
- super(ZopeSAXParseException, self).__init__(info, exception)
-
- @property
- def _v(self):
- # BWC for testing only
- return self.evalue
class ParserInfo(object):
r"""
@@ -418,7 +406,7 @@ def processxmlfile(file, context, testing=False):
try:
parser.parse(src)
except SAXParseException:
- reraise(ZopeSAXParseException(sys.exc_info()[1]),
+ reraise(ZopeSAXParseException(src, sys.exc_info()[1]),
None, sys.exc_info()[2])