Skip to content

Commit

Permalink
use exception syntax compatible with py 3
Browse files Browse the repository at this point in the history
  • Loading branch information
diekhans committed Feb 3, 2017
1 parent f26636c commit 858cbdc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eutils/queryservice.py
Expand Up @@ -309,15 +309,15 @@ def _cacheable(r):
try:
xml = lxml.etree.fromstring(r.text.encode('utf-8'))
raise EutilsRequestError('{r.reason} ({r.status_code}): {error}'.format(r=r, error=xml.find('ERROR').text))
except Exception, ex:
except Exception as ex:
raise EutilsNCBIError('Error parsing response object from NCBI: {}'.format(ex))

if any(bad_word in r.text for bad_word in ['<error>', '<ERROR>']):
if r.text is not None:
try:
xml = lxml.etree.fromstring(r.text.encode('utf-8'))
raise EutilsRequestError('{r.reason} ({r.status_code}): {error}'.format(r=r, error=xml.find('ERROR').text))
except Exception, ex:
except Exception as ex:
raise EutilsNCBIError('Error parsing response object from NCBI: {}'.format(ex))

if '<h1 class="error">Access Denied</h1>' in r.text:
Expand Down

0 comments on commit 858cbdc

Please sign in to comment.