8000 fix: add padding to PyMethodDef layout (#65) · denosaurs/deno_python@43e4957 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43e4957

Browse files
authored
fix: add padding to PyMethodDef layout (#65)
* fix pyMethodDef layout * comment
1 parent 8bd3556 commit 43e4957

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/python.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ export class PyObject {
452452
}
453453
return new PyObject(list);
454454
} else if (v instanceof Callback) {
455-
const pyMethodDef = new Uint8Array(8 + 8 + 4 + 8);
455+
// https://docs.python.org/3/c-api/structures.html#c.PyMethodDef
456+
// there are extra 4 bytes of padding after ml_flags field
457+
const pyMethodDef = new Uint8Array(8 + 8 + 4 + 4 + 8);
456458
const view = new DataView(pyMethodDef.buffer);
457459
const LE =
458460
new Uint8Array(new Uint32Array([0x12345678]).buffer)[0] !== 0x7;
@@ -471,7 +473,7 @@ export class PyObject {
471473
);
472474
view.setInt32(16, 0x1 | 0x2, LE);
473475
view.setBigUint64(
474-
20,
476+
24,
475477
BigInt(Deno.UnsafePointer.value(Deno.UnsafePointer.of(nameBuf)!)),
476478
LE,
477479
);

0 commit comments

Comments
 (0)
0