[CentOS-devel] git.centos.org maint 19th June 15:00 UTC

Laurentiu Pancescu lpancescu at gmail.com
Fri Jun 23 18:10:19 UTC 2017


Hi Pat,

On 23/06/17 15:15, Pat Riehecky wrote:
> 
> https://git.centos.org/blob/centos-git-common.git/master/centos.git.repolist.py 
> 
> Traceback (most recent call last):
>    File "./centos.git.repolist.py", line 73, in <module>
>      main()
>    File "./centos.git.repolist.py", line 68, in main
>      repos = get_repo_list(url=options.url, branch=options.branch, 
> projectpath=options.project)
>    File "./centos.git.repolist.py", line 52, in get_repo_list
>      repos = json.loads(payload)
>    File "/usr/lib64/python2.7/site-packages/simplejson/__init__.py", 
> line 516, in loads
>      return _default_decoder.decode(s)
>    File "/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 
> 374, in decode
>      obj, end = self.raw_decode(s)
>    File "/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 
> 404, in raw_decode
>      return self.scan_once(s, idx=_w(s, idx).end())
> simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 
> (char 0)

I was a bit confused why I see a JSON decoder exception when the server 
returns a 404 status.  There's a try block there, but python-requests 
doesn't raise an exception on HTTP error codes by default.  May I 
suggest either explicitly checking req.status_code against 200 before 
parsing, or adding a call to req.raise_for_status() to the try block? 
This would better handle such errors for the future, and would have 
pointed you from the beginning in the right direction.

Best regards,
Laurențiu


More information about the CentOS-devel mailing list