[XML-SIG] [ pyxml-Bugs-597861 ] FromXmlFile needs try: finally:

noreply@sourceforge.net noreply@sourceforge.net
Tue, 20 Aug 2002 10:50:17 -0700


Bugs item #597861, was opened at 2002-08-21 03:50
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=106473&aid=597861&group_id=6473

Category: DOM
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Alastair Rankine (alastair)
Assigned to: Nobody/Anonymous (nobody)
Summary: FromXmlFile needs try: finally:

Initial Comment:
So that the file is closed in case an exception is thrown from within the parser. Inside xml.dom.ext.reader.Sax2.py:

change:

    fp = open(fileName, 'r')
    rv = FromXmlStream(fp, ownerDocument, validate, keepAllWs, catName,
                       saxHandlerClass, parser)
    fp.close()
    return rv

to:

    fp = open(fileName, 'r')
    try:
        rv = FromXmlStream(fp, ownerDocument, validate, keepAllWs, catName,
                       saxHandlerClass, parser)
    finally:
        fp.close()
    return rv


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=106473&aid=597861&group_id=6473