diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2014-01-17 23:22:25 +0100 |
|---|---|---|
| committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-01-17 23:22:25 +0100 |
| commit | 61fef89ccb1da6826061875a3771b4955266a5c7 (patch) | |
| tree | bb52817d034d58da8ff8ea413779baf9ade157cf /src/lxml/saxparser.pxi | |
| parent | 84504dbde18c7f55a297d8af5b07e3d5ae3eeb03 (diff) | |
| download | python-lxml-61fef89ccb1da6826061875a3771b4955266a5c7.tar.gz | |
fix several error/exception handling cases throughout the code base
Diffstat (limited to 'src/lxml/saxparser.pxi')
| -rw-r--r-- | src/lxml/saxparser.pxi | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/lxml/saxparser.pxi b/src/lxml/saxparser.pxi index 64f32002..2388ba8d 100644 --- a/src/lxml/saxparser.pxi +++ b/src/lxml/saxparser.pxi @@ -287,6 +287,8 @@ cdef void _handleSaxStart( c_localname, None) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxTargetStart( @@ -344,6 +346,8 @@ cdef void _handleSaxTargetStart( c_localname, element) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxStartNoNs(void* ctxt, const_xmlChar* c_name, @@ -361,6 +365,8 @@ cdef void _handleSaxStartNoNs(void* ctxt, const_xmlChar* c_name, _pushSaxStartEvent(context, c_ctxt, NULL, c_name, None) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxTargetStartNoNs(void* ctxt, const_xmlChar* c_name, @@ -386,6 +392,8 @@ cdef void _handleSaxTargetStartNoNs(void* ctxt, const_xmlChar* c_name, _pushSaxStartEvent(context, c_ctxt, NULL, c_name, element) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef _callTargetSaxStart(_SaxParserContext context, @@ -435,6 +443,8 @@ cdef void _handleSaxEnd(void* ctxt, const_xmlChar* c_localname, _pushSaxNsEndEvents(context) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxEndNoNs(void* ctxt, const_xmlChar* c_name) with gil: @@ -451,6 +461,8 @@ cdef void _handleSaxEndNoNs(void* ctxt, const_xmlChar* c_name) with gil: _pushSaxEndEvent(context, NULL, c_name, node) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef tuple NS_END_EVENT = ('end-ns', None) @@ -487,6 +499,8 @@ cdef void _handleSaxData(void* ctxt, const_xmlChar* c_data, int data_len) with g c_data[:data_len].decode('utf8')) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxTargetDoctype(void* ctxt, const_xmlChar* c_name, @@ -502,6 +516,8 @@ cdef void _handleSaxTargetDoctype(void* ctxt, const_xmlChar* c_name, funicodeOrNone(c_system)) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxStartDocument(void* ctxt) with gil: @@ -518,6 +534,8 @@ cdef void _handleSaxStartDocument(void* ctxt) with gil: context.startDocument(c_doc) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxPI(void* ctxt, const_xmlChar* c_target, @@ -535,6 +553,8 @@ cdef void _handleSaxPI(void* ctxt, const_xmlChar* c_target, context.events_iterator._events.append(('pi', pi)) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxPIEvent(void* ctxt, const_xmlChar* target, @@ -544,8 +564,14 @@ cdef void _handleSaxPIEvent(void* ctxt, const_xmlChar* target, context = <_SaxParserContext>c_ctxt._private context._origSaxPI(ctxt, target, data) c_node = _findLastEventNode(c_ctxt) - if c_node is not NULL: + if c_node is NULL: + return + try: context.pushEvent('pi', c_node) + except: + context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxTargetComment(void* ctxt, const_xmlChar* c_data) with gil: @@ -560,6 +586,8 @@ cdef void _handleSaxTargetComment(void* ctxt, const_xmlChar* c_data) with gil: context.events_iterator._events.append(('comment', comment)) except: context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef void _handleSaxComment(void* ctxt, const_xmlChar* text) with gil: @@ -568,8 +596,14 @@ cdef void _handleSaxComment(void* ctxt, const_xmlChar* text) with gil: context = <_SaxParserContext>c_ctxt._private context._origSaxComment(ctxt, text) c_node = _findLastEventNode(c_ctxt) - if c_node is not NULL: + if c_node is NULL: + return + try: context.pushEvent('comment', c_node) + except: + context._handleSaxException(c_ctxt) + finally: + return # swallow any further exceptions cdef inline xmlNode* _findLastEventNode(xmlparser.xmlParserCtxt* c_ctxt): |
