Skip to content

Enum value "from" causes invalid Python code generation #1254

@ARMartinelli

Description

@ARMartinelli

I'm not sure if this is considered a bug, but using the word "from" as an enum value causes invalid Python code when generating with the Kaitai compiler.

For example, running:

kaitai-struct-compiler --read-write --target python example.ksy

produces Python code that is not executable, because it includes a statement like:

from = 0

which is invalid since "from" is a reserved keyword in Python.

Here is a minimal .ksy example that reproduces the issue:

meta:
  id: my_test
  endian: be
seq:
  - id: test_field
    type: b1
    enum: to_from
enums:
  to_from:
    0: from
    1: to

I'm using Kaitai Struct Compiler version 0.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions