aclark4life / vanity

Get package download statistics from PyPI
GNU General Public License v2.0
66 stars 14 forks source link

Python 3 JSON issue: ValueError: Expecting value: line 1 column 1 (char 0) #17

Closed aclark4life closed 8 years ago

aclark4life commented 9 years ago

Python 3 --json issue:

$ python3 vanity.py vanity --json
Traceback (most recent call last):
  File "vanity.py", line 260, in <module>
    vanity()
  File "vanity.py", line 232, in vanity
    verbose=verbose)
  File "vanity.py", line 102, in count_downloads
    for urls, data in get_release_info([package], json=json):
  File "vanity.py", line 173, in get_release_info
    data = get_jsonparsed_data(PYPI_JSON % package)
  File "vanity.py", line 136, in get_jsonparsed_data
    return json.loads(data)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
mattjegan commented 8 years ago

I tried fixing this using the requests module which can handle the json conversion for us. I have submitted a PR. Sorry if I haven't followed some convention, this is my first PR.

aclark4life commented 8 years ago

Fixed in #23, thanks