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

Tagged types can not be nested #8

Open
jcea opened this issue Dec 14, 2017 · 1 comment
Open

Tagged types can not be nested #8

jcea opened this issue Dec 14, 2017 · 1 comment

Comments

@jcea
Copy link

jcea commented Dec 14, 2017

Tagged types using cbor.TagMapper() can not be nested:

#!/usr/bin/env python3

import cbor
from collections import namedtuple

test = namedtuple('test', 'x y')

cbor_test = cbor.ClassTag(15309737, test, tuple, lambda x: test(*x))
cbor_set = cbor.ClassTag(15309738, set, tuple, lambda x: set(x))
mapper = cbor.TagMapper(class_tags=(cbor_test, cbor_set),
                        raise_on_unknown_tag=True)
x = {7:test(1,{1,2,3})}
y = mapper.loads(mapper.dumps(x))

print(y == x)


Traceback (most recent call last):
  File "./z.py", line 13, in <module>
    y = mapper.loads(mapper.dumps(x))
  File "/usr/local/lib/python3.6/site-packages/cbor/tagmap.py", line 99, in dumps
    return dumps(self.encode(obj))
ValueError: cannot serialize unknown object: {1, 2, 3}
@jcea
Copy link
Author

jcea commented Dec 14, 2017

I have a patch for this. Should I do a pull request here or in BitBucket?

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

1 participant