Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expat parser locks XML source file if ContentHandler raises an exception #47089

Closed
craigneuro mannequin opened this issue May 12, 2008 · 3 comments
Closed

Expat parser locks XML source file if ContentHandler raises an exception #47089

craigneuro mannequin opened this issue May 12, 2008 · 3 comments
Labels
topic-XML type-bug An unexpected behavior, bug, or error

Comments

@craigneuro
Copy link
Mannequin

craigneuro mannequin commented May 12, 2008

BPO 2840
Nosy @serhiy-storchaka
Superseder
  • bpo-15388: SAX parse (ExpatParser) leaks file handle when given filename input
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-02-05.20:06:25.010>
    created_at = <Date 2008-05-12.19:44:33.484>
    labels = ['expert-XML', 'type-bug']
    title = 'Expat parser locks XML source file if ContentHandler raises an exception'
    updated_at = <Date 2013-02-05.20:06:25.009>
    user = 'https://bugs.python.org/craigneuro'

    bugs.python.org fields:

    activity = <Date 2013-02-05.20:06:25.009>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-02-05.20:06:25.010>
    closer = 'serhiy.storchaka'
    components = ['XML']
    creation = <Date 2008-05-12.19:44:33.484>
    creator = 'craigneuro'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 2840
    keywords = []
    message_count = 3.0
    messages = ['66754', '113251', '181475']
    nosy_count = 3.0
    nosy_names = ['craigneuro', 'BreamoreBoy', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '15388'
    type = 'behavior'
    url = 'https://bugs.python.org/issue2840'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @craigneuro
    Copy link
    Mannequin Author

    craigneuro mannequin commented May 12, 2008

    This was observed in Python 2.5.2 on Windows XP. Run this code in IDLE:

    import xml.sax
    from xml.sax.handler import ContentHandler
    class C(ContentHandler):
    	def startElement(self, name, attrs):
    		assert False
    
    xml.sax.parse(xml_path, C())

    Where "xml_path" points to a well-formed XML file. This will raise an
    AssertionError. Then, attempt to modify or delete the XML file that was
    specified; it's still locked by the Python process.

    Deleting the ContentHandler does not unlock it. There doesn't seem any
    way to unlock it aside from terminating the Python process.

    If the ContentHandler doesn't raise an exception or error, the file is
    unlocked properly.

    @craigneuro craigneuro mannequin added topic-XML type-bug An unexpected behavior, bug, or error labels May 12, 2008
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Aug 8, 2010

    I can't reproduce this on Windows Vista from the command line with 2.7 or py3k. Can someone confirm that I'm correct?

    @serhiy-storchaka
    Copy link
    Member

    This is a duplicate of bpo-15388. Parser doesn't close an input source's stream if an exception raised.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-XML type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant