mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 03:43:13 +03:00
Simplify C error handling (#9021)
This commit is contained in:
commit
ef683e9d78
|
@ -338,12 +338,6 @@ static const char *no_palette = "image has no palette";
|
|||
static const char *readonly = "image is readonly";
|
||||
/* static const char* no_content = "image has no content"; */
|
||||
|
||||
void *
|
||||
ImagingError_OSError(void) {
|
||||
PyErr_SetString(PyExc_OSError, "error when accessing file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
ImagingError_MemoryError(void) {
|
||||
return PyErr_NoMemory();
|
||||
|
@ -369,11 +363,6 @@ ImagingError_ValueError(const char *message) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ImagingError_Clear(void) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* HELPERS */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -54,7 +54,7 @@ ImagingSavePPM(Imaging im, const char *outfile) {
|
|||
|
||||
fp = fopen(outfile, "wb");
|
||||
if (!fp) {
|
||||
(void)ImagingError_OSError();
|
||||
PyErr_SetString(PyExc_OSError, "error when accessing file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,8 +270,6 @@ ImagingSectionLeave(ImagingSectionCookie *cookie);
|
|||
/* Exceptions */
|
||||
/* ---------- */
|
||||
|
||||
extern void *
|
||||
ImagingError_OSError(void);
|
||||
extern void *
|
||||
ImagingError_MemoryError(void);
|
||||
extern void *
|
||||
|
@ -280,8 +278,6 @@ extern void *
|
|||
ImagingError_Mismatch(void); /* maps to ValueError by default */
|
||||
extern void *
|
||||
ImagingError_ValueError(const char *message);
|
||||
extern void
|
||||
ImagingError_Clear(void);
|
||||
|
||||
/* Transform callbacks */
|
||||
/* ------------------- */
|
||||
|
|
|
@ -645,7 +645,7 @@ ImagingNewInternal(const char *mode, int xsize, int ysize, int dirty) {
|
|||
return im;
|
||||
}
|
||||
|
||||
ImagingError_Clear();
|
||||
PyErr_Clear();
|
||||
|
||||
// Try to allocate the image once more with smallest possible block size
|
||||
MUTEX_LOCK(&ImagingDefaultArena.mutex);
|
||||
|
|
Loading…
Reference in New Issue
Block a user