diff --git a/shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala b/shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala index a2b14273c..2d5c1044b 100644 --- a/shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala +++ b/shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala @@ -466,10 +466,10 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig) } override def enumDeclaration(curClass: String, enumName: String, enumColl: Seq[(Long, String)]): Unit = { - importList.add("from enum import Enum") + importList.add("from enum import IntEnum") out.puts - out.puts(s"class ${type2class(enumName)}(Enum):") + out.puts(s"class ${type2class(enumName)}(IntEnum):") out.inc enumColl.foreach { case (id: Long, label: String) => out.puts(s"$label = ${translator.doIntLiteral(id)}") } out.dec diff --git a/shared/src/main/scala/io/kaitai/struct/translators/PythonTranslator.scala b/shared/src/main/scala/io/kaitai/struct/translators/PythonTranslator.scala index a4f445c54..2a4e21f81 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/PythonTranslator.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/PythonTranslator.scala @@ -85,7 +85,7 @@ class PythonTranslator(provider: TypeProvider, importList: ImportList) extends B s"int(${translate(s)}$add)" } override def enumToInt(v: Ast.expr, et: EnumType): String = - s"${translate(v)}.value" + s"int(${translate(v)})" override def boolToInt(v: Ast.expr): String = s"int(${translate(v)})" override def floatToInt(v: Ast.expr): String =