@@ -110,48 +110,49 @@ pub inline fn typeError(msg: [:0]const u8, args: anytype) !void {
110110 return errorFormat (@ptrCast (c .PyExc_TypeError ), msg , args );
111111}
112112
113- pub inline fn typeErrorObject (msg : [:0 ]const u8 , args : anytype ) ? * Object {
114- typeError (msg , args ) catch return null ;
115- unreachable ;
113+ pub inline fn typeErrorObject (comptime value : anytype , msg : [:0 ]const u8 , args : anytype ) @TypeOf ( value ) {
114+ typeError (msg , args ) catch {} ;
115+ return value ;
116116}
117117
118118// Helper that is the equivalent to `SystemError(msg)`
119119pub inline fn systemError (msg : [:0 ]const u8 , args : anytype ) ! void {
120120 return errorFormat (@ptrCast (c .PyExc_SystemError ), msg , args );
121121}
122122
123- pub inline fn systemErrorObject (msg : [:0 ]const u8 , args : anytype ) ? * Object {
124- systemError (msg , args ) catch return null ;
125- unreachable ;
123+ pub inline fn systemErrorObject (comptime value : anytype , msg : [:0 ]const u8 , args : anytype ) @TypeOf ( value ) {
124+ systemError (msg , args ) catch {} ;
125+ return value ;
126126}
127127
128128// Helper that is the equivalent to `ValueError(msg)`
129129pub inline fn valueError (msg : [:0 ]const u8 , args : anytype ) ! void {
130130 return errorFormat (@ptrCast (c .PyExc_ValueError ), msg , args );
131131}
132132
133- pub inline fn valueErrorObject (msg : [:0 ]const u8 , args : anytype ) ? * Object {
134- valueError (msg , args ) catch return null ;
135- unreachable ;
133+ pub inline fn valueErrorObject (comptime value : anytype , msg : [:0 ]const u8 , args : anytype ) @TypeOf ( value ) {
134+ valueError (msg , args ) catch {} ;
135+ return value ;
136136}
137137
138138// Helper that is the equivalent to `AttributeError(msg)`
139139pub inline fn attributeError (msg : [:0 ]const u8 , args : anytype ) ! void {
140140 return errorFormat (@ptrCast (c .PyExc_AttributeError ), msg , args );
141141}
142142
143- pub inline fn attributeErrorObject (msg : [:0 ]const u8 , args : anytype ) ? * Object {
144- attributeError (msg , args ) catch return null ;
145- unreachable ;
143+ pub inline fn attributeErrorObject (comptime value : anytype , msg : [:0 ]const u8 , args : anytype ) @TypeOf ( value ) {
144+ attributeError (msg , args ) catch {} ;
145+ return value ;
146146}
147147
148148pub inline fn memoryError () ! void {
149149 _ = c .PyErr_NoMemory ();
150150 return error .PyError ;
151151}
152152
153- pub inline fn memoryErrorObject () ? * Object {
154- return @ptrCast (c .PyErr_NoMemory ());
153+ pub inline fn memoryErrorObject (comptime value : anytype ) @TypeOf (value ) {
154+ memoryError () catch {};
155+ return value ;
155156}
156157
157158// Clear a reference to **Object or *?*Object
0 commit comments