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

Dumping Python dict yields invalid HSD #7

Open
awvwgk opened this issue Apr 6, 2020 · 1 comment
Open

Dumping Python dict yields invalid HSD #7

awvwgk opened this issue Apr 6, 2020 · 1 comment

Comments

@awvwgk
Copy link
Member

awvwgk commented Apr 6, 2020

Since keys in Python dicts are case sensitive, one can easily build a dict that has no valid HSD representation. Unfortunately, this is exactly what happens with the implementation in this repo:

>>> import hsd
>>> print(hsd.dumps({'key': 0.0, 'Key': 1.0}))
key = 0.0
Key = 1.0

The preferable solution would be an exception from the serializer or a way to normalize a dict for HSD dumping.

Together with #6, the deserialization of the above HSD then yields {'key': [0.0, 1.0]}, so it cannot even be identified as invalid HSD.

@awvwgk awvwgk changed the title Dumping Python dict yield invalid HSD Dumping Python dict yields invalid HSD Apr 6, 2020
@awvwgk
Copy link
Member Author

awvwgk commented Apr 7, 2020

Trying again with this dict

{'key': 0.0, 'Key': 1.0, ' key': -1.0, 'Key ': True}

reveals that the serializer cannot correctly cope with spaces as well.

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