Skip to main content
2 of 3
added 418 characters in body; added 196 characters in body
Edan Maor
  • 1.1k
  • 9
  • 10

Edit:

My problem below has been "solved", and it's a problem with the fact that I'm getting back gzip-compressed data from stackapps. See the SO Answer. I'm still unsure why this happens only on my computer (possible reason: routers in my network adding content-headers), but I'm guessing this should be fixed in the wrapper itself.

Come to think of it, the wrapper should probably be requesting gzip-compress data in the first place, to save download time.

Original question

I'm having problems using the library. I'm doing the following:

site = stackexchange.Site(stackexchange.StackOverflow)
user = site.user(userid)

And I'm getting the following exception:

ValueError at /answers
No JSON object could be decoded

After some debugging, I see that the line which throws the error is: dump = json.load(conn) (around line 410). When I try printing the urllib object I get back (conn), I get the following:

\x1f\x8b\x08\x00\x00\x00\x00\x00\x04\x00\xed\xbd\x07`\x1cI\x96%&/m\xca{\x7fJ\xf5J\xd7\xe0t\xa1\x08\x80`\x ...

I don't have any experience with urllib, so I'm not sure if that's a good output, although it doesn't look right to me (by contrast, opening http://www.google.com gives back actual meaningful text).

Any ideas as to what the problem could be?

Edit: Just running the code snippet in your question in IDLE is causing a problem.

Edan Maor
  • 1.1k
  • 9
  • 10