ecordell / pymacaroons

A Python Macaroon Library
pymacaroons.readthedocs.org
MIT License
79 stars 23 forks source link

Accept either bytes or string when deserializing #18

Closed ecordell closed 8 years ago

ecordell commented 8 years ago

If a token is a bytes object, deserializing throws an unhelpful error:

>>> Macaroon.deserialize(token)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/pymacaroons/macaroon.py", line 40, in deserialize
    return serializer.deserialize(serialized)
  File "/usr/local/lib/python3.4/dist-packages/pymacaroons/serializers/binary_serializer.py", line 42, in deserialize
    serialized + "=" * (-len(serialized) % 4)
TypeError: can't concat bytes to str

Instead, it should accept either bytes or a string.

joeljames commented 8 years ago

Submitted a PR for this issue: https://github.com/ecordell/pymacaroons/pull/19