From d12b784744d5f6e007350cea5bb348c9e1645388 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Tue, 5 Sep 2023 15:22:32 +0100 Subject: [PATCH] Fix: remove PyTuple#getRawItem (#30) --- pydust/src/pytypes.zig | 5 +++-- pydust/src/types/tuple.zig | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pydust/src/pytypes.zig b/pydust/src/pytypes.zig index 0e3d965d..4a0cfef2 100644 --- a/pydust/src/pytypes.zig +++ b/pydust/src/pytypes.zig @@ -251,7 +251,7 @@ fn Init(comptime name: [:0]const u8, comptime definition: type, comptime Instanc return null; } - const tuple = py.PyTuple{ .obj = .{ .py = args } }; + const tuple: py.PyTuple = .{ .obj = .{ .py = args } }; const argsSize = tuple.getSize() catch return null; const argLen = @typeInfo(@typeInfo(initSig.argsParam.?.type.?).Pointer.child).Struct.fields.len; if (argsSize != argLen) { @@ -261,7 +261,8 @@ fn Init(comptime name: [:0]const u8, comptime definition: type, comptime Instanc var pyArgs: []*ffi.PyObject = py.allocator.alloc(*ffi.PyObject, argLen) catch return null; for (0..argLen) |i| { - pyArgs[i] = tuple.getRawItem(@intCast(i)) catch return null; + const item = tuple.getItem(@intCast(i)) catch return null; + pyArgs[i] = item.py; } return pyArgs; diff --git a/pydust/src/types/tuple.zig b/pydust/src/types/tuple.zig index b78e6199..83632ce6 100644 --- a/pydust/src/types/tuple.zig +++ b/pydust/src/types/tuple.zig @@ -38,14 +38,6 @@ pub const PyTuple = extern struct { } } - pub fn getRawItem(self: *const PyTuple, idx: isize) !*ffi.PyObject { - if (ffi.PyTuple_GetItem(self.obj.py, @intCast(idx))) |item| { - return item; - } else { - return PyError.Propagate; - } - } - /// Insert a reference to object o at position pos of the tuple. /// /// Warning: steals a reference to value.