kimgr / asn1ate

A Python library for translating ASN.1 into other forms.
Other
69 stars 41 forks source link

Emits invalid python for `BOOLEAN true` #49

Open DeviceIntelligenceUser opened 7 years ago

DeviceIntelligenceUser commented 7 years ago

With input Foo DEFINITIONS ::= BEGIN bar BOOLEAN ::= true END, I get output containing bar = univ.Boolean(true). I would expect to get (1) a parse error; or (2) valid (non-erroring) python code. (The 'T' in 'true' should be capitalized, True; currently I get a NameError)

The full output is

# Auto-generated by asn1ate v.0.5.1.dev from foo.asn
# (last modified on 2016-11-28 19:08:26.094569)

from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful

bar = univ.Boolean(true)
kimgr commented 6 years ago

Sorry this took so long (my time for asn1ate has been very limited), but I got around to experimenting with this today. It turns out that true is not a valid value for a BOOLEAN -- the valid values are TRUE or FALSE. There may be cases where a valueref called true should be resolved to TRUE, but the case you describe above is simply invalid input.