Skip to content

Commit

Permalink
Removed _avif.HAVE_AVIF and _avif.VERSION (#11)
Browse files Browse the repository at this point in the history
* Removed unused attributes

* Decrement reference count

---------

Co-authored-by: Andrew Murray <[email protected]>
  • Loading branch information
radarhere and radarhere authored Dec 15, 2024
1 parent 4eaa6b7 commit bdb24f9
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,36 +1006,15 @@ static PyMethodDef avifMethods[] = {

static int
setup_module(PyObject *m) {
PyObject *d = PyModule_GetDict(m);

PyObject *v = PyUnicode_FromString(avifVersion());
if (PyDict_SetItemString(d, "libavif_version", v) < 0) {
Py_DECREF(v);
return -1;
}
Py_DECREF(v);

v = Py_True;
Py_INCREF(v);
if (PyDict_SetItemString(d, "HAVE_AVIF", v) < 0) {
Py_DECREF(v);
if (PyType_Ready(&AvifDecoder_Type) < 0 || PyType_Ready(&AvifEncoder_Type) < 0) {
return -1;
}
Py_DECREF(v);

v = Py_BuildValue(
"(iii)", AVIF_VERSION_MAJOR, AVIF_VERSION_MINOR, AVIF_VERSION_PATCH
);

if (PyDict_SetItemString(d, "VERSION", v) < 0) {
Py_DECREF(v);
return -1;
}
Py_DECREF(v);
PyObject *d = PyModule_GetDict(m);
PyObject *v = PyUnicode_FromString(avifVersion());
PyDict_SetItemString(d, "libavif_version", v ? v : Py_None);
Py_XDECREF(v);

if (PyType_Ready(&AvifDecoder_Type) < 0 || PyType_Ready(&AvifEncoder_Type) < 0) {
return -1;
}
return 0;
}

Expand All @@ -1052,6 +1031,7 @@ PyInit__avif(void) {

m = PyModule_Create(&module_def);
if (setup_module(m) < 0) {
Py_DECREF(m);
return NULL;
}

Expand Down

0 comments on commit bdb24f9

Please sign in to comment.