Treat empty body as no body in parse_api_error

If BeautifulSoup is called when html5lib is installed, it will use
its parser when no markup_type is specified. In those cases, an empty
body is included in the parsed output when no dody is included in the
input string.

Change-Id: Ibc7201434b8f09b82cb96f5ffabceba4fbf74de7
Closes-Bug: #1650514
This commit is contained in:
Javier Pena 2016-12-16 12:44:18 +01:00 committed by Javier Peña
parent 363514d364
commit bcf1b2babb
1 changed files with 1 additions and 1 deletions

View File

@ -34,7 +34,7 @@ except ImportError:
def parse_api_error(api_error_html):
error_html = bs4.BeautifulSoup(api_error_html)
body = error_html.find('body')
if not body:
if (not body or not body.text):
return None
h1 = body.find('h1')
if h1: