leeroybrun / glacier-vault-remove

Remove all archives stored inside an Amazon Glacier vault, even if you have a huge number of them.
379 stars 50 forks source link

Fix Python 3 complains about JSON decoding #13

Closed muojp closed 8 years ago

muojp commented 8 years ago

Hi, thanks for merging my previous Pull-Request ( #12 ) quickly. Here's another fix for supporting Python 3.x.

Parsing JSON data raises an exception on Python 3.4:

Traceback (most recent call last):
  File "removeVault.py", line 92, in <module>
    inventory = json.loads(job.get_output().read())
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

This is a common migration issue happen between 2 and 3.

Ref: http://stackoverflow.com/questions/6862770/python-3-let-json-object-accept-bytes-or-let-urlopen-output-strings

I put a fix on this and confirmed deleting archives work well both on 2.7 & 3.4.

leeroybrun commented 8 years ago

Great, thanks!