Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python bindings: produce better error when format not recognized #47

Open
rogpeppe opened this issue Aug 22, 2017 · 1 comment
Open

Comments

@rogpeppe
Copy link
Contributor

When we pass an unknown format to macaroon.serialize, it produces this error:

>>> m.serialize(format='json1')
Exception KeyError: ('json1',) in 'macaroons.Macaroon.version' ignored
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bindings/python/macaroons.pyx", line 179, in macaroons.Macaroon.serialize (bindings/python/macaroons.c:2215)
    if self.is_json(format):
  File "bindings/python/macaroons.pyx", line 289, in macaroons.Macaroon.is_json (bindings/python/macaroons.c:3914)
    '1': False}[v]
KeyError: 'json1'

It would be nice if it made it clearer what the error signifies (for example by raising an exception which mentions that it's an unknown format, possibly stating the possible format values, as there is no documentation for that, AFAICS)

@rescrv
Copy link
Owner

rescrv commented Aug 23, 2017

This would be great to have. I didn't document the format well because I'd like to move to the v2 binary format (which is much more compact) and the well-specified JSON equivalent. Unfortunately, I never had time to investigate UTF-8 issues to support JSON correctly, and I didn't want to support it incorrectly.

I've just moved to a new job and don't know if I have the cycles to make this fix, but wanted to give you a signal that this would be a beneficial change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants