mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Decrement reference count
This commit is contained in:
parent
6b71090828
commit
c63b0ca210
|
@ -3820,15 +3820,29 @@ _get_stats(PyObject *self, PyObject *args) {
|
|||
if (!d) {
|
||||
return NULL;
|
||||
}
|
||||
PyDict_SetItemString(d, "new_count", PyLong_FromLong(arena->stats_new_count));
|
||||
PyDict_SetItemString(
|
||||
d, "allocated_blocks", PyLong_FromLong(arena->stats_allocated_blocks));
|
||||
PyDict_SetItemString(
|
||||
d, "reused_blocks", PyLong_FromLong(arena->stats_reused_blocks));
|
||||
PyDict_SetItemString(
|
||||
d, "reallocated_blocks", PyLong_FromLong(arena->stats_reallocated_blocks));
|
||||
PyDict_SetItemString(d, "freed_blocks", PyLong_FromLong(arena->stats_freed_blocks));
|
||||
PyDict_SetItemString(d, "blocks_cached", PyLong_FromLong(arena->blocks_cached));
|
||||
PyObject *new_count = PyLong_FromLong(arena->stats_new_count);
|
||||
PyDict_SetItemString(d, "new_count", new_count);
|
||||
Py_XDECREF(new_count);
|
||||
|
||||
PyObject *allocated_blocks = PyLong_FromLong(arena->stats_allocated_blocks);
|
||||
PyDict_SetItemString(d, "allocated_blocks", allocated_blocks);
|
||||
Py_XDECREF(allocated_blocks);
|
||||
|
||||
PyObject *reused_blocks = PyLong_FromLong(arena->stats_reused_blocks);
|
||||
PyDict_SetItemString(d, "reused_blocks", reused_blocks);
|
||||
Py_XDECREF(reused_blocks);
|
||||
|
||||
PyObject *reallocated_blocks = PyLong_FromLong(arena->stats_reallocated_blocks);
|
||||
PyDict_SetItemString(d, "reallocated_blocks", reallocated_blocks);
|
||||
Py_XDECREF(reallocated_blocks);
|
||||
|
||||
PyObject *freed_blocks = PyLong_FromLong(arena->stats_freed_blocks);
|
||||
PyDict_SetItemString(d, "freed_blocks", freed_blocks);
|
||||
Py_XDECREF(freed_blocks);
|
||||
|
||||
PyObject *blocks_cached = PyLong_FromLong(arena->blocks_cached);
|
||||
PyDict_SetItemString(d, "blocks_cached", blocks_cached);
|
||||
Py_XDECREF(blocks_cached);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -4197,16 +4211,18 @@ setup_module(PyObject *m) {
|
|||
#ifdef HAVE_LIBJPEG
|
||||
{
|
||||
extern const char *ImagingJpegVersion(void);
|
||||
PyDict_SetItemString(
|
||||
d, "jpeglib_version", PyUnicode_FromString(ImagingJpegVersion()));
|
||||
PyObject *jpeglib_version = PyUnicode_FromString(ImagingJpegVersion());
|
||||
PyDict_SetItemString(d, "jpeglib_version", jpeglib_version);
|
||||
Py_DECREF(jpeglib_version);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENJPEG
|
||||
{
|
||||
extern const char *ImagingJpeg2KVersion(void);
|
||||
PyDict_SetItemString(
|
||||
d, "jp2klib_version", PyUnicode_FromString(ImagingJpeg2KVersion()));
|
||||
PyObject *jp2klib_version = PyUnicode_FromString(ImagingJpeg2KVersion());
|
||||
PyDict_SetItemString(d, "jp2klib_version", jp2klib_version);
|
||||
Py_DECREF(jp2klib_version);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4215,8 +4231,9 @@ setup_module(PyObject *m) {
|
|||
have_libjpegturbo = Py_True;
|
||||
#define tostr1(a) #a
|
||||
#define tostr(a) tostr1(a)
|
||||
PyDict_SetItemString(
|
||||
d, "libjpeg_turbo_version", PyUnicode_FromString(tostr(LIBJPEG_TURBO_VERSION)));
|
||||
PyObject *libjpeg_turbo_version = PyUnicode_FromString(tostr(LIBJPEG_TURBO_VERSION));
|
||||
PyDict_SetItemString(d, "libjpeg_turbo_version", libjpeg_turbo_version);
|
||||
Py_DECREF(libjpeg_turbo_version);
|
||||
#undef tostr
|
||||
#undef tostr1
|
||||
#else
|
||||
|
@ -4230,8 +4247,9 @@ setup_module(PyObject *m) {
|
|||
have_libimagequant = Py_True;
|
||||
{
|
||||
extern const char *ImagingImageQuantVersion(void);
|
||||
PyDict_SetItemString(
|
||||
d, "imagequant_version", PyUnicode_FromString(ImagingImageQuantVersion()));
|
||||
PyObject *imagequant_version = PyUnicode_FromString(ImagingImageQuantVersion());
|
||||
PyDict_SetItemString(d, "imagequant_version", imagequant_version);
|
||||
Py_DECREF(imagequant_version);
|
||||
}
|
||||
#else
|
||||
have_libimagequant = Py_False;
|
||||
|
@ -4248,16 +4266,18 @@ setup_module(PyObject *m) {
|
|||
PyModule_AddIntConstant(m, "FIXED", Z_FIXED);
|
||||
{
|
||||
extern const char *ImagingZipVersion(void);
|
||||
PyDict_SetItemString(
|
||||
d, "zlib_version", PyUnicode_FromString(ImagingZipVersion()));
|
||||
PyObject *zlibversion = PyUnicode_FromString(ImagingZipVersion());
|
||||
PyDict_SetItemString(d, "zlib_version", zlibversion);
|
||||
Py_DECREF(zlibversion);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBTIFF
|
||||
{
|
||||
extern const char *ImagingTiffVersion(void);
|
||||
PyDict_SetItemString(
|
||||
d, "libtiff_version", PyUnicode_FromString(ImagingTiffVersion()));
|
||||
PyObject *libtiff_version = PyUnicode_FromString(ImagingTiffVersion());
|
||||
PyDict_SetItemString(d, "libtiff_version", libtiff_version);
|
||||
Py_DECREF(libtiff_version);
|
||||
|
||||
// Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7
|
||||
PyObject *support_custom_tags;
|
||||
|
@ -4280,7 +4300,9 @@ setup_module(PyObject *m) {
|
|||
Py_INCREF(have_xcb);
|
||||
PyModule_AddObject(m, "HAVE_XCB", have_xcb);
|
||||
|
||||
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version));
|
||||
PyObject *pillow_version = PyUnicode_FromString(version);
|
||||
PyDict_SetItemString(d, "PILLOW_VERSION", pillow_version);
|
||||
Py_DECREF(pillow_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -950,6 +950,8 @@ _is_intent_supported(CmsProfileObject *self, int clut) {
|
|||
return Py_None;
|
||||
}
|
||||
PyDict_SetItem(result, id, entry);
|
||||
Py_DECREF(id);
|
||||
Py_DECREF(entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1532,6 +1534,7 @@ setup_module(PyObject *m) {
|
|||
v = PyUnicode_FromFormat("%d.%d", vn / 1000, (vn / 10) % 100);
|
||||
}
|
||||
PyDict_SetItemString(d, "littlecms_version", v);
|
||||
Py_DECREF(v);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1129,11 +1129,17 @@ font_getvaraxes(FontObject *self) {
|
|||
axis = master->axis[i];
|
||||
|
||||
list_axis = PyDict_New();
|
||||
PyDict_SetItemString(
|
||||
list_axis, "minimum", PyLong_FromLong(axis.minimum / 65536));
|
||||
PyDict_SetItemString(list_axis, "default", PyLong_FromLong(axis.def / 65536));
|
||||
PyDict_SetItemString(
|
||||
list_axis, "maximum", PyLong_FromLong(axis.maximum / 65536));
|
||||
PyObject *minimum = PyLong_FromLong(axis.minimum / 65536);
|
||||
PyDict_SetItemString(list_axis, "minimum", minimum);
|
||||
Py_XDECREF(minimum);
|
||||
|
||||
PyObject *def = PyLong_FromLong(axis.def / 65536);
|
||||
PyDict_SetItemString(list_axis, "default", def);
|
||||
Py_XDECREF(def);
|
||||
|
||||
PyObject *maximum = PyLong_FromLong(axis.maximum / 65536);
|
||||
PyDict_SetItemString(list_axis, "maximum", maximum);
|
||||
Py_XDECREF(maximum);
|
||||
|
||||
for (j = 0; j < name_count; j++) {
|
||||
error = FT_Get_Sfnt_Name(self->face, j, &name);
|
||||
|
@ -1144,6 +1150,7 @@ font_getvaraxes(FontObject *self) {
|
|||
if (name.name_id == axis.strid) {
|
||||
axis_name = Py_BuildValue("y#", name.string, name.string_len);
|
||||
PyDict_SetItemString(list_axis, "name", axis_name);
|
||||
Py_XDECREF(axis_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1359,6 +1366,7 @@ setup_module(PyObject *m) {
|
|||
|
||||
v = PyUnicode_FromFormat("%d.%d.%d", major, minor, patch);
|
||||
PyDict_SetItemString(d, "freetype2_version", v);
|
||||
Py_DECREF(v);
|
||||
|
||||
#ifdef HAVE_RAQM
|
||||
#if defined(HAVE_RAQM_SYSTEM) || defined(HAVE_FRIBIDI_SYSTEM)
|
||||
|
@ -1376,6 +1384,7 @@ setup_module(PyObject *m) {
|
|||
PyDict_SetItemString(d, "HAVE_RAQM", v);
|
||||
PyDict_SetItemString(d, "HAVE_FRIBIDI", v);
|
||||
PyDict_SetItemString(d, "HAVE_HARFBUZZ", v);
|
||||
Py_DECREF(v);
|
||||
if (have_raqm) {
|
||||
#ifdef RAQM_VERSION_MAJOR
|
||||
v = PyUnicode_FromString(raqm_version_string());
|
||||
|
@ -1383,6 +1392,7 @@ setup_module(PyObject *m) {
|
|||
v = Py_None;
|
||||
#endif
|
||||
PyDict_SetItemString(d, "raqm_version", v);
|
||||
Py_DECREF(v);
|
||||
|
||||
#ifdef FRIBIDI_MAJOR_VERSION
|
||||
{
|
||||
|
|
|
@ -194,6 +194,7 @@ match(PyObject *self, PyObject *args) {
|
|||
if (lut[lut_idx]) {
|
||||
PyObject *coordObj = Py_BuildValue("(nn)", col_idx, row_idx);
|
||||
PyList_Append(ret, coordObj);
|
||||
Py_XDECREF(coordObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,6 +231,7 @@ get_on_pixels(PyObject *self, PyObject *args) {
|
|||
if (row[col_idx]) {
|
||||
PyObject *coordObj = Py_BuildValue("(nn)", col_idx, row_idx);
|
||||
PyList_Append(ret, coordObj);
|
||||
Py_XDECREF(coordObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +242,9 @@ static int
|
|||
setup_module(PyObject *m) {
|
||||
PyObject *d = PyModule_GetDict(m);
|
||||
|
||||
PyDict_SetItemString(d, "__version", PyUnicode_FromString("0.1"));
|
||||
PyObject *version = PyUnicode_FromString("0.1");
|
||||
PyDict_SetItemString(d, "__version", version);
|
||||
Py_DECREF(version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
11
src/_webp.c
11
src/_webp.c
|
@ -949,8 +949,10 @@ addAnimFlagToModule(PyObject *m) {
|
|||
|
||||
void
|
||||
addTransparencyFlagToModule(PyObject *m) {
|
||||
PyModule_AddObject(
|
||||
m, "HAVE_TRANSPARENCY", PyBool_FromLong(!WebPDecoderBuggyAlpha()));
|
||||
PyObject *have_transparency = PyBool_FromLong(!WebPDecoderBuggyAlpha());
|
||||
if (PyModule_AddObject(m, "HAVE_TRANSPARENCY", have_transparency)) {
|
||||
Py_DECREF(have_transparency);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -960,8 +962,9 @@ setup_module(PyObject *m) {
|
|||
addAnimFlagToModule(m);
|
||||
addTransparencyFlagToModule(m);
|
||||
|
||||
PyDict_SetItemString(
|
||||
d, "webpdecoder_version", PyUnicode_FromString(WebPDecoderVersion_str()));
|
||||
PyObject *webpdecoder_version = PyUnicode_FromString(WebPDecoderVersion_str());
|
||||
PyDict_SetItemString(d, "webpdecoder_version", webpdecoder_version);
|
||||
Py_DECREF(webpdecoder_version);
|
||||
|
||||
#ifdef HAVE_WEBPANIM
|
||||
/* Ready object types */
|
||||
|
|
Loading…
Reference in New Issue
Block a user