Browse files

Hack to make Entrez work with its XML parser and other Bio parsers

Previously, Entrez's _open can either work with Entrez.read / Entrez.parse or
the other parsers (SeqIO, Medline), but not both. This was because Entrez's XML
parser expects binary data while the other parsers expect strings.
  • Loading branch information...
1 parent 4e163ca commit 1550588186a823ab57a528e56557e80ba3f459ea @bow bow committed Dec 19, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 Bio/Entrez/Parser.py
View
4 Bio/Entrez/Parser.py
@@ -172,6 +172,10 @@ def __init__(self, validate):
def read(self, handle):
"""Set up the parser and let it parse the XML results"""
+ # HACK: remove Bio._py3k handle conversion, since the Entrez XML parser
+ # expects binary data
+ if handle.__class__.__name__ == 'EvilHandleHack':
+ handle = handle._handle
if hasattr(handle, "closed") and handle.closed:
#Should avoid a possible Segmentation Fault, see:
#http://bugs.python.org/issue4877

0 comments on commit 1550588

Please sign in to comment.