Skip to content

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

@rogpeppe

Description

@rogpeppe

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions