You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RFC 8610 defines the CDDL standard prelude in appendix D. This defines tdate.
zcbor yields an exception: KeyError: 'tdate' when is is reference in CDDL.
import zcbor
cddl_str = """
date_type = {
creation: tdate
}
"""
cddl_res = zcbor.zcbor.zcbor.DataTranslator.from_cddl(cddl_str, 100)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 293, in from_cddl
my_types[my_type].post_validate()
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 937, in post_validate
none_keys = [child for child in self.value if not child.elem_has_key()]
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 937, in
none_keys = [child for child in self.value if not child.elem_has_key()]
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 928, in elem_has_key
or (self.type == "OTHER" and self.my_types[self.value].elem_has_key())
KeyError: 'tdate'
If I add the RFC8610 prelude definition of tdate the following exception is raise:
tdate = #6.0(tstr)
"""
cddl_res = zcbor.zcbor.zcbor.DataTranslator.from_cddl(cddl_str, 100)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 293, in from_cddl
my_types[my_type].post_validate()
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 940, in post_validate
raise TypeError(
TypeError: Map member(s) must have key: [creation:OTHER'tdate'] pointing to [#6.0TSTR]
I have not tested other types defined in the RFC 8610 standard prelude. Perhaps none are defined?
The text was updated successfully, but these errors were encountered:
cddl_res = zcbor.zcbor.zcbor.DataTranslator.from_cddl(cddl_str, 100)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 293, in from_cddl
my_types[my_type].post_validate()
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 940, in post_validate
raise TypeError(
TypeError: Map member(s) must have key: [creation:#6.0TSTR] pointing to []
The prelude is added by default when using the CLI, but not when using the Python module. The prelude can be found in the repo at zcbor/prelude.cddl, you can programmatically append it to the cddl_str. I will look into making it easier to add the when using the python module.
Your second comment seems to fail because you are defining a map, but the member has no well-formed key. Try e.g.
RFC 8610 defines the CDDL standard prelude in appendix D. This defines tdate.
zcbor yields an exception: KeyError: 'tdate' when is is reference in CDDL.
import zcbor
cddl_str = """
date_type = {
creation: tdate
}
"""
cddl_res = zcbor.zcbor.zcbor.DataTranslator.from_cddl(cddl_str, 100)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 293, in from_cddl
my_types[my_type].post_validate()
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 937, in post_validate
none_keys = [child for child in self.value if not child.elem_has_key()]
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 937, in
none_keys = [child for child in self.value if not child.elem_has_key()]
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 928, in elem_has_key
or (self.type == "OTHER" and self.my_types[self.value].elem_has_key())
KeyError: 'tdate'
If I add the RFC8610 prelude definition of tdate the following exception is raise:
import zcbor
cddl_str = """
date_type = {
creation: tdate
}
tdate = #6.0(tstr)
"""
cddl_res = zcbor.zcbor.zcbor.DataTranslator.from_cddl(cddl_str, 100)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 293, in from_cddl
my_types[my_type].post_validate()
File "/usr/local/lib/python3.8/dist-packages/zcbor/zcbor/zcbor.py", line 940, in post_validate
raise TypeError(
TypeError: Map member(s) must have key: [creation:OTHER'tdate'] pointing to [#6.0TSTR]
I have not tested other types defined in the RFC 8610 standard prelude. Perhaps none are defined?
The text was updated successfully, but these errors were encountered: