Skip to content

Commit

Permalink
Fix: remove PyTuple#getRawItem (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Sep 5, 2023
1 parent ab60cf3 commit d12b784
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pydust/src/pytypes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions pydust/src/types/tuple.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d12b784

Please sign in to comment.