diff --git a/pydust/src/modules.zig b/pydust/src/modules.zig index d86a8ae0..699e777e 100644 --- a/pydust/src/modules.zig +++ b/pydust/src/modules.zig @@ -50,7 +50,7 @@ pub fn Module(comptime name: [:0]const u8, comptime definition: type) type { /// A function to initialize the Python module from its definition. pub fn init() !py.PyObject { - var pyModuleDef = try py.allocator.create(ffi.PyModuleDef); + const pyModuleDef = try py.allocator.create(ffi.PyModuleDef); pyModuleDef.* = ffi.PyModuleDef{ .m_base = ffi.PyModuleDef_Base{ .ob_base = ffi.PyObject{ diff --git a/pydust/src/pytypes.zig b/pydust/src/pytypes.zig index d3c95f30..4e28b101 100644 --- a/pydust/src/pytypes.zig +++ b/pydust/src/pytypes.zig @@ -509,7 +509,7 @@ fn GC(comptime definition: type) type { } fn tp_clear(pyself: *ffi.PyObject) callconv(.C) c_int { - var self: *PyTypeStruct(definition) = @ptrCast(pyself); + const self: *PyTypeStruct(definition) = @ptrCast(pyself); clearFields(self.state); return 0; } @@ -562,7 +562,7 @@ fn GC(comptime definition: type) type { } inline fn pyClear(obj: *ffi.PyObject) void { - var objRef = @constCast(&obj); + const objRef = @constCast(&obj); const objOld = objRef.*; objRef.* = undefined; py.decref(objOld); @@ -665,7 +665,7 @@ fn Members(comptime definition: type) type { // We compute the offset of the attribute within the type, and then the value field within the attribute. // Although the value within the attribute should always be 0 since it's the only field. - var offset = @offsetOf(PyTypeStruct(definition), "state") + @offsetOf(definition, field.name) + @offsetOf(field.type, "value"); + const offset = @offsetOf(PyTypeStruct(definition), "state") + @offsetOf(definition, field.name) + @offsetOf(field.type, "value"); const T = @typeInfo(field.type).Struct.fields[0].type; diff --git a/pydust/src/types/bytes.zig b/pydust/src/types/bytes.zig index 8c8429a8..149b153a 100644 --- a/pydust/src/types/bytes.zig +++ b/pydust/src/types/bytes.zig @@ -60,7 +60,7 @@ test "PyBytes" { var ps = try PyBytes.create(a); defer ps.decref(); - var ps_slice = try ps.asSlice(); + const ps_slice = try ps.asSlice(); try testing.expectEqual(a.len, ps_slice.len); try testing.expectEqual(a.len, try ps.length()); try testing.expectEqual(@as(u8, 0), ps_slice[ps_slice.len]); diff --git a/pydust/src/types/str.zig b/pydust/src/types/str.zig index 52762b03..f2d85c3d 100644 --- a/pydust/src/types/str.zig +++ b/pydust/src/types/str.zig @@ -105,7 +105,7 @@ test "PyString" { ps = try ps.appendSlice(b); defer ps.decref(); - var ps_slice = try ps.asSlice(); + const ps_slice = try ps.asSlice(); // Null-terminated strings have len == non-null bytes, but are guaranteed to have a null byte // when indexed by their length.