[Jython-checkins] jython: Handle diff in exceptions if using built-in Xerces. Also unbreak installer
jim.baker
jython-checkins at python.org
Wed Feb 3 19:25:44 EST 2016
https://hg.python.org/jython/rev/ad6ac3cc574d
changeset: 7894:ad6ac3cc574d
user: Jim Baker <jim.baker at rackspace.com>
date: Wed Feb 03 17:25:35 2016 -0700
summary:
Handle diff in exceptions if using built-in Xerces. Also unbreak installer build.
files:
Lib/xml/sax/drivers2/drv_javasax.py | 29 +++++++++++-----
build.xml | 1 -
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/Lib/xml/sax/drivers2/drv_javasax.py b/Lib/xml/sax/drivers2/drv_javasax.py
--- a/Lib/xml/sax/drivers2/drv_javasax.py
+++ b/Lib/xml/sax/drivers2/drv_javasax.py
@@ -45,7 +45,7 @@
except ImportError:
jaxp = 0
-from java.lang import String
+from java.lang import String, Exception as JException
class SAXUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, message):
@@ -56,17 +56,21 @@
def _wrap_sax_exception(e):
- # work around issues in how we report exception - note this is an
- # implementation detail, so it's not guaranteed to always report
- # this exception. But in the end, it's from Xerces, so should be OK.
- if "org.apache.xerces.impl.io.MalformedByteSequenceException" in str(e.getException().getClass()):
+ # Work around issues in how we report exceptions to using
+ # code. Note this is an implementation detail, so some assumptions
+ # are required. But if this identification fails, a reasonable exception
+ # will still be thrown.
+ #
+ # Because of some differences in how Oracle packages Xerces, also catch
+ # on the parse method itself.
+ if "MalformedByteSequenceException" in str(e.getException()):
return SAXUnicodeDecodeError(str(e))
return _exceptions.SAXParseException(e.message,
e.exception,
SimpleLocator(e.columnNumber,
- e.lineNumber,
- e.publicId,
- e.systemId))
+ e.lineNumber,
+ e.publicId,
+ e.systemId))
class JyErrorHandlerWrapper(javasax.ErrorHandler):
def __init__(self, err_handler):
@@ -163,7 +167,14 @@
def parse(self, source):
"Parse an XML document from a URL or an InputSource."
- self._parser.parse(JyInputSourceWrapper(source))
+ try:
+ self._parser.parse(JyInputSourceWrapper(source))
+ except JException as e:
+ # Handle the difference in how Oracle packages Xerces...
+ if "MalformedByteSequenceException" in str(e):
+ raise SAXUnicodeDecodeError(str(e))
+ else:
+ raise
def getFeature(self, name):
return self._parser.getFeature(name)
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -611,7 +611,6 @@
<zipfileset src="${extlibs.dir}/jnr-netdb-1.1.5.jar"/>
<zipfileset src="${extlibs.dir}/jnr-posix-3.0.23.jar"/>
<zipfileset src="${extlibs.dir}/jnr-constants-0.9.0.jar"/>
- <zipfileset src="extlibs/xml-apis-2.11.0.jar" excludes="META-INF/services/*"/>
<zipfileset src="extlibs/xercesImpl-2.11.0.jar" excludes="META-INF/services/*"/>
<rule pattern="org.apache.xml.**" result="org.python.apache.xml. at 1"/>
<rule pattern="org.apache.xerces.**" result="org.python.apache.xerces. at 1"/>
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list