Skip to content

Commit c027d13

Browse files
committed
Python: use self as default _root only in top-level types
... as in Java, see https://github.com/kaitai-io/kaitai_struct_compiler/blob/829a14f1e33e8e48eeae726c8a287a5967bcb668/shared/src/main/scala/io/kaitai/struct/languages/JavaCompiler.scala#L153 This commit was extracted from the `serialization` branch (originally e776c98), see #255
1 parent 91a1074 commit c027d13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
101101
out.inc
102102
out.puts("self._io = _io")
103103
out.puts("self._parent = _parent")
104-
out.puts("self._root = _root if _root else self")
104+
if (name == rootClassName) {
105+
out.puts("self._root = _root if _root else self")
106+
} else {
107+
out.puts("self._root = _root")
108+
}
105109

106110
if (isHybrid)
107111
out.puts("self._is_le = _is_le")

0 commit comments

Comments
 (0)