Skip to content

PyModule_AddObject fix for Python 3.10#5194

Merged
radarhere merged 3 commits intopython-pillow:masterfrom
radarhere:python310
Jan 12, 2021
Merged

PyModule_AddObject fix for Python 3.10#5194
radarhere merged 3 commits intopython-pillow:masterfrom
radarhere:python310

Conversation

@radarhere
Copy link
Copy Markdown
Member

@radarhere radarhere commented Jan 9, 2021

Resolves #5193

The first commit adds python3 -c "from PIL import Image" to .ci/test.sh - for whatever reason, this fails in Python 3.10, while our pytest command does not.

The second commit replaces instances like

#ifdef HAVE_XCB
    PyModule_AddObject(m, "HAVE_XCB", Py_True);
#else
    PyModule_AddObject(m, "HAVE_XCB", Py_False);
#endif

with

    PyObject *have_xcb;
#ifdef HAVE_XCB
    have_xcb = Py_True;
#else
    have_xcb = Py_False;
#endif
    Py_INCREF(have_xcb);
    PyModule_AddObject(m, "HAVE_XCB", have_xcb);

This is per the example in https://docs.python.org/3/c-api/module.html#c.PyModule_AddObject, which calls Py_INCREF before PyModule_AddObject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3.10: segfault due to invalid pointer

2 participants