Skip to content

Commit 94e2fdc

Browse files
committed
remove unnecessary binding
1 parent 144889d commit 94e2fdc

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

serialize_py/codegen_result.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def get_root(_io=None, check=True):
1212
# https://github.com/kaitai-io/kaitai_struct/issues/1245
1313
root.pages__to_write = False
1414
root.header = kaitaistruct_sqlite3.Sqlite3.DatabaseHeader(root._io, root, root._root)
15-
header = root.header
1615
def init_header(header):
1716
header.magic = b'SQLite format 3\x00'
1817
header.page_size_raw = 4096 # 0x1000
@@ -25,10 +24,9 @@ def init_header(header):
2524
header.file_change_counter = 1
2625
header.num_pages = 2
2726
header.first_freelist_trunk_page = kaitaistruct_sqlite3.Sqlite3.FreelistTrunkPagePointer(root._io, header, header._root)
28-
first_freelist_trunk_page = header.first_freelist_trunk_page
2927
def init_first_freelist_trunk_page(first_freelist_trunk_page):
3028
first_freelist_trunk_page.page_number = 0
31-
init_first_freelist_trunk_page(first_freelist_trunk_page)
29+
init_first_freelist_trunk_page(header.first_freelist_trunk_page)
3230
header.num_freelist_pages = 0
3331
header.schema_cookie = 1
3432
header.schema_format = 4
@@ -41,7 +39,7 @@ def init_first_freelist_trunk_page(first_freelist_trunk_page):
4139
header.reserved_header_bytes = 20 * b'\x00'
4240
header.version_valid_for = 1
4341
header.sqlite_version_number = 3050001 # 0x2e8a11
44-
init_header(header)
42+
init_header(root.header)
4543
if check:
4644
root._check()
4745
return root

serialize_py/kaitai_serialize_codegen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ def codegen(
383383
print(f"{ind}{ids}{on}.{key} = {mod}.{root_cln}.{member}(root._io, {on}, {on}._root)", file=out) # long
384384
# avoid shadowing global variables
385385
local_key = get_local_key(key, global_names)
386-
print(f"{ind}{ids}{local_key} = {on}.{key}", file=out)
387386
# print(f"{ind}{ids}if 1:", file=out) # no block scope
388387
# print(f"{ind}{ids}if {local_key} := {on}.{key}:", file=out) # no block scope
389388
# TypeError: 'int' object does not support the context manager protocol
@@ -406,7 +405,7 @@ def codegen(
406405
module_map,
407406
global_names,
408407
)
409-
print(f"{ind}{ids}init_{key}({local_key})", file=out) # "init_" prefix
408+
print(f"{ind}{ids}init_{key}({on}.{key})", file=out) # "init_" prefix
410409
# print(f"{ind}{ids}{key}_init({local_key})", file=out) # "_init" suffix
411410

412411
# some user-defined types need this

0 commit comments

Comments
 (0)