python script aborts on Ubuntu 16.04: No JSON object could be decoded
M. Fioretti
mfioretti at nexaima.net
Tue Aug 28 04:47:32 UTC 2018
On 2018-08-27 21:53, M. Fioretti wrote:
> ... If I rerun the script after installing
> this module, the result is whatI pasted below (the different URL is
> because this time I ran the script using the test file provided by its
> developer. But even if I run the version with hardwired values it is
> the same. So it is likely a library/python module version problem, at
> least partly.
or maybe not. If I add this statement
print repr(response)
right before the one that prints the error message below, it prints:
<Response [200]>
IIUC, this means that shaarli answers with an HTTP response code
*instead* of something in JSON format, as expected, and is this that
causes the error:
"JSONDecodeError: Expecting value..."
by simple_json. Am I right? If yes, what now?
Thanks,
Marco
>
> DEBUG: New Shaarli bookmark: {'url':
> u'http://links.drwho.virtadpt.net/marks', 'tags': [], 'description':
> '', 'private': True, 'title': u'Unmark'}
> INFO: Sending link http://links.drwho.virtadpt.net/marks
> INFO: Starting new HTTP connection (1): 127.0.0.1
> DEBUG: "POST /shaarli HTTP/1.1" 301 308
> DEBUG: "GET /shaarli/ HTTP/1.1" 200 2344
> Traceback (most recent call last):
> File "./unmark_dump_to_shaarli-nolinks.py", line 149, in <module>
> logger.debug(json.dumps(response.json()))
> File "/usr/lib/python2.7/dist-packages/requests/models.py", line 808,
> in json
> return complexjson.loads(self.text, **kwargs)
> File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line
> 516, in loads
> return _default_decoder.decode(s)
> File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line
> 370, in decode
> obj, end = self.raw_decode(s)
> File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line
> 400, in raw_decode
> return self.scan_once(s, idx=_w(s, idx).end())
> simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1
> (char 0)
>
> --
> http://mfioretti.com
--
http://mfioretti.com
More information about the ubuntu-users
mailing list