Skip to content

Avoid using deprecated API in CPython 3.9#2253

Merged
wjakob merged 1 commit into
pybind:masterfrom
bstaletic:py39
Jun 30, 2020
Merged

Avoid using deprecated API in CPython 3.9#2253
wjakob merged 1 commit into
pybind:masterfrom
bstaletic:py39

Conversation

@bstaletic

Copy link
Copy Markdown
Collaborator

PyEval_InitThreads() will be deprecated once python 3.9 is released.

This is a quote from the what's new page. Considering the advanced capabilities of pybind11, with regards to GIL, I don't know if this is the right thing to do about this deprecation.

The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are now deprecated and will be removed in Python 3.11. Calling PyEval_InitThreads() now does nothing. The GIL is initialized by Py_Initialize() since Python 3.7.

@bstaletic bstaletic changed the title Avoid using deprecated API in python 3.9 Avoid using deprecated API in CPython 3.9 Jun 15, 2020
Comment thread include/pybind11/detail/internals.h Outdated
internals_ptr = new internals();
#if defined(WITH_THREAD)
PyEval_InitThreads();
#if PY_VERSION_HEX >= 0x03090000

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidentally first wrote 0x03080000 here and it broke the tests, even though the CPython docs say that PyEval_InitThreads() doesn't do anything ever since 3.7.

This only makes me less certain that this pull request actually works.

@bstaletic
bstaletic force-pushed the py39 branch 2 times, most recently from b18c075 to 101dc49 Compare June 18, 2020 17:38
The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are
now deprecated and will be removed in Python 3.11. Calling
PyEval_InitThreads() now does nothing. The GIL is initialized by
Py_Initialize() since Python 3.7.

@trixirt trixirt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this build problem on fedora rawhide, which uses 3.9.
I have reviewed the docs, this call should not be necessary.
And this change fixes the problem

@wjakob

wjakob commented Jun 30, 2020

Copy link
Copy Markdown
Member

Thanks @bstaletic. I didn't quite follow your comment above, but I'll merge this for now (and we can revisit if problems do arise.)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants