[Biopython-dev] [Biopython - Bug #3267] (New) Empty files trigger Bio.SeqIO exception from Bio.SeqIO.SeqXML under Jython

redmine at redmine.open-bio.org redmine at redmine.open-bio.org
Thu Jul 21 14:55:02 UTC 2011


Issue #3267 has been reported by Peter Cock.

----------------------------------------
Bug #3267: Empty files trigger Bio.SeqIO exception from Bio.SeqIO.SeqXML under Jython
https://redmine.open-bio.org/issues/3267

Author: Peter Cock
Status: New
Priority: Normal
Assignee: 
Category: 
Target version: 
URL: 


Buildbot test failures following addition of seqxml support to Bio.SeqIO

$ jython test_SeqIO.py
Traceback (most recent call last):
  File "test_SeqIO.py", line 392, in <module>
    records = list(SeqIO.parse(handle, t_format))
  File "/Users/pjcock/jython2.5.1/Lib/site-packages/Bio/SeqIO/__init__.py", line 536, in parse
    for r in i:
  File "/Users/pjcock/jython2.5.1/Lib/site-packages/Bio/SeqIO/SeqXmlIO.py", line 53, in __iter__
    for event,node in self._events:
  File "/Users/pjcock/jython2.5.1/Lib/xml/dom/pulldom.py", line 231, in next
    rc = self.getEvent()
  File "/Users/pjcock/jython2.5.1/Lib/xml/dom/pulldom.py", line 275, in _slurp
    self.parser.parse(self.stream)
  File "/Users/pjcock/jython2.5.1/Lib/xml/sax/drivers2/drv_javasax.py", line 141, in parse
    self._parser.parse(JyInputSourceWrapper(source))
  File "/Users/pjcock/jython2.5.1/Lib/xml/sax/drivers2/drv_javasax.py", line 58, in fatalError
    self._err_handler.fatalError(_wrap_sax_exception(exc))
  File "/Users/pjcock/jython2.5.1/Lib/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:1: Premature end of file.

Turns out to be due to different handling of empty XML files under Jython.

I will file a bug in Jython shortly (currently http://www.jython.org/ is down).

Reduced test case:

import sys
print sys.version
from StringIO import StringIO
from xml.dom import pulldom
from xml.sax import SAXParseException
handle = StringIO() # simulate empty file
try:
    for event,node in pulldom.parse(handle):
        print event
except SAXParseException, e:
    print repr(e)
    print "Line number", e.getLineNumber()
    print "Column number", e.getColumnNumber()
print "Done"


$ python2.5 ../../sax_empty_xml.py 
2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)]
SAXParseException('no element found',)
Line number 1
Column number 0
Done

$ python2.6 ../../sax_empty_xml.py 
2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)]
SAXParseException('no element found',)
Line number 1
Column number 0
Done

$ jython ../../sax_empty_xml.py 
2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)]
SAXParseException(u'Premature end of file.',)
Line number 1
Column number 1
Done


Notice (a) different exception description, (b) different column number:



----------------------------------------
You have received this notification because this email was added to the New Issue Alert plugin


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here and login: http://redmine.open-bio.org




More information about the Biopython-dev mailing list