@@ -46,8 +46,7 @@ wrap_patch(git_patch *patch)
46
46
PyObject * py_hunk ;
47
47
size_t i , hunk_amounts ;
48
48
49
- if (!patch )
50
- Py_RETURN_NONE ;
49
+ assert (patch );
51
50
52
51
py_patch = PyObject_New (Patch , & PatchType );
53
52
if (py_patch ) {
@@ -78,9 +77,7 @@ PyDoc_STRVAR(Patch_delta__doc__, "Get the delta associated with a patch.");
78
77
PyObject *
79
78
Patch_delta__get__ (Patch * self )
80
79
{
81
- if (!self -> patch )
82
- Py_RETURN_NONE ;
83
-
80
+ assert (self -> patch );
84
81
return wrap_diff_delta (git_patch_get_delta (self -> patch ));
85
82
}
86
83
@@ -93,11 +90,8 @@ Patch_line_stats__get__(Patch *self)
93
90
size_t context , additions , deletions ;
94
91
int err ;
95
92
96
- if (!self -> patch )
97
- Py_RETURN_NONE ;
98
-
99
- err = git_patch_line_stats (& context , & additions , & deletions ,
100
- self -> patch );
93
+ assert (self -> patch );
94
+ err = git_patch_line_stats (& context , & additions , & deletions , self -> patch );
101
95
if (err < 0 )
102
96
return Error_set (err );
103
97
@@ -171,12 +165,11 @@ Patch_create_from(PyObject *self, PyObject *args, PyObject *kwds)
171
165
err = git_patch_from_buffers (& patch , oldbuf , oldbuflen , old_as_path ,
172
166
newbuf , newbuflen , new_as_path , & opts );
173
167
}
174
-
168
+
175
169
if (err < 0 )
176
170
return Error_set (err );
177
171
178
172
return wrap_patch (patch );
179
-
180
173
}
181
174
182
175
@@ -186,24 +179,18 @@ PyDoc_STRVAR(Patch_patch__doc__,
186
179
PyObject *
187
180
Patch_patch__get__ (Patch * self )
188
181
{
189
- git_buf buf = {NULL };
190
- int err = GIT_ERROR ;
191
- PyObject * py_patch = NULL ;
192
-
193
- err = git_patch_to_buf (& buf , self -> patch );
194
-
195
- if (!self -> patch )
196
- Py_RETURN_NONE ;
197
-
198
- if (err < 0 )
199
- goto cleanup ;
182
+ git_buf buf = {NULL };
183
+ int err ;
184
+ PyObject * py_patch ;
200
185
201
- py_patch = to_unicode (buf .ptr , NULL , NULL );
202
- git_buf_free (& buf );
186
+ assert (self -> patch );
187
+ err = git_patch_to_buf (& buf , self -> patch );
188
+ if (err < 0 )
189
+ return Error_set (err );
203
190
204
- cleanup :
191
+ py_patch = to_unicode ( buf . ptr , NULL , NULL );
205
192
git_buf_free (& buf );
206
- return ( err < 0 ) ? Error_set ( err ) : py_patch ;
193
+ return py_patch ;
207
194
}
208
195
209
196
PyMethodDef Patch_methods [] = {
0 commit comments