Skip to content

Commit ef683e9

Browse files
authored
Simplify C error handling (#9021)
2 parents 01267f9 + 8309962 commit ef683e9

File tree

4 files changed

+2
-17
lines changed

4 files changed

+2
-17
lines changed

src/_imaging.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,6 @@ static const char *no_palette = "image has no palette";
338338
static const char *readonly = "image is readonly";
339339
/* static const char* no_content = "image has no content"; */
340340

341-
void *
342-
ImagingError_OSError(void) {
343-
PyErr_SetString(PyExc_OSError, "error when accessing file");
344-
return NULL;
345-
}
346-
347341
void *
348342
ImagingError_MemoryError(void) {
349343
return PyErr_NoMemory();
@@ -369,11 +363,6 @@ ImagingError_ValueError(const char *message) {
369363
return NULL;
370364
}
371365

372-
void
373-
ImagingError_Clear(void) {
374-
PyErr_Clear();
375-
}
376-
377366
/* -------------------------------------------------------------------- */
378367
/* HELPERS */
379368
/* -------------------------------------------------------------------- */

src/libImaging/File.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ImagingSavePPM(Imaging im, const char *outfile) {
5454

5555
fp = fopen(outfile, "wb");
5656
if (!fp) {
57-
(void)ImagingError_OSError();
57+
PyErr_SetString(PyExc_OSError, "error when accessing file");
5858
return 0;
5959
}
6060

src/libImaging/Imaging.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ ImagingSectionLeave(ImagingSectionCookie *cookie);
270270
/* Exceptions */
271271
/* ---------- */
272272

273-
extern void *
274-
ImagingError_OSError(void);
275273
extern void *
276274
ImagingError_MemoryError(void);
277275
extern void *
@@ -280,8 +278,6 @@ extern void *
280278
ImagingError_Mismatch(void); /* maps to ValueError by default */
281279
extern void *
282280
ImagingError_ValueError(const char *message);
283-
extern void
284-
ImagingError_Clear(void);
285281

286282
/* Transform callbacks */
287283
/* ------------------- */

src/libImaging/Storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ ImagingNewInternal(const char *mode, int xsize, int ysize, int dirty) {
645645
return im;
646646
}
647647

648-
ImagingError_Clear();
648+
PyErr_Clear();
649649

650650
// Try to allocate the image once more with smallest possible block size
651651
MUTEX_LOCK(&ImagingDefaultArena.mutex);

0 commit comments

Comments
 (0)