Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyModule_AddObject fix for Python 3.10 #5194

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

radarhere
Copy link
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.

.ci/test.sh Show resolved Hide resolved
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