leerssej / freebase-python

Automatically exported from code.google.com/p/freebase-python
Other
0 stars 0 forks source link

_raise_service_error Fails when there is no Body in the Response #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a write query you know will fail 
2. mqlwrite(query)
3. Freebase will return a status 400 without a Request body

What is the expected output? What do you see instead?

_raise_service_error does not fail, and mqlwrite raises a MetawebError.

What version of the product are you using? On what operating system?

1.6.0

Please provide any additional information below.

Here is how I have fixed the bug in locally.  See line 88 of httpclients.py.  
This fix will accommodate scenarios where no body is returned, but still 
properly raise the MetawebError. 

if resp.status_code != 200:
  try:
    body = resp.body
  except AttributeError:
    body = "" 
  self._raise_service_error(url, resp.status_code, 
                                      resp.headers['content-type'], body)

Original issue reported on code.google.com by Will.Merydith on 7 Feb 2011 at 9:35

GoogleCodeExporter commented 9 years ago
Fixed in 1.0.x, thanks Will. 

Original comment by rtp@google.com on 8 Feb 2011 at 10:33