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