Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-45434: Only exclude <stdlib.h> in Python 3.11 limited C API#29027

Merged
vstinner merged 3 commits intopython:mainpython/cpython:mainfrom
vstinner:capi_compatCopy head branch name to clipboard
Oct 19, 2021
Merged

bpo-45434: Only exclude <stdlib.h> in Python 3.11 limited C API#29027
vstinner merged 3 commits intopython:mainpython/cpython:mainfrom
vstinner:capi_compatCopy head branch name to clipboard

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 18, 2021

The Python 3.11 limited C API no longer includes stdlib.h, stdio.h,
string.h and errno.h.

  • Exclude Py_MEMCPY() from Python 3.11 limited C API.
  • xxlimited C extension is now built with Python 3.11 limited C API.

https://bugs.python.org/issue45434

The Python 3.11 limited C API no longer includes stdlib.h, stdio.h,
string.h and errno.h.

* Exclude Py_MEMCPY() from Python 3.11 limited C API.
* xxlimited C extension is now built with Python 3.11 limited C API.
@vstinner
Copy link
Member Author

@Yhg1s @ronaldoussoren @encukou @tiran: Does it look a reasonable approach to you? Only change the Python 3.11 limited C API, but leave other APIs unchanged?

Include/pyport.h Outdated Show resolved Hide resolved
Doc/whatsnew/3.11.rst Outdated Show resolved Hide resolved
@ronaldoussoren
Copy link
Contributor

I not sure if doing this is worth the effort, this makes the headers more complicated and only affects the few extensions that target the stable ABI and want to use API's introduced in 3.11.

@tiran
Copy link
Member

tiran commented Oct 18, 2021

I not sure if doing this is worth the effort, this makes the headers more complicated and only affects the few extensions that target the stable ABI and want to use API's introduced in 3.11.

I think it's worth doing. In the long run it's going to make Python.h lean and mean.

@vstinner
Copy link
Member Author

@tiran: I addresssed your review.

@vstinner
Copy link
Member Author

I not sure if doing this is worth the effort, this makes the headers more complicated and only affects the few extensions that target the stable ABI and want to use API's introduced in 3.11.

You only have to do this update work once. Once you added the missing #include, the code remains compatible with older Python versions, and becomes "future proof" (no need to add again these include).

Comment on lines 567 to 570
* The Python 3.11 limited C API no longer includes ``<stdlib.h>``,
``<stdio.h>``, ``<errno.h>`` and ``<string.h>``:
if ``Py_LIMITED_API >= 0x030b0000``. C extensions using these headers must
now include them explicitly.
Copy link
Member

Choose a reason for hiding this comment

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

The whatsnew entry is hard to understand.

Suggested change
* The Python 3.11 limited C API no longer includes ``<stdlib.h>``,
``<stdio.h>``, ``<errno.h>`` and ``<string.h>``:
if ``Py_LIMITED_API >= 0x030b0000``. C extensions using these headers must
now include them explicitly.
* ``<Python.h>`` no longer includes the header files ``<stdlib.h>``,
``<stdio.h>``, ``<errno.h>`` and ``<string.h>`` when ``Py_LIMITED_API``
is set to ``0x030b0000`` (3.11) or higher. C extensions should explicitly
include the header files after ``#include <Python.h>``.

Copy link
Member Author

Choose a reason for hiding this comment

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

I confess that it's hard to understand. I copied your rephrased paragraph, thanks.

@vstinner vstinner merged commit 52af075 into python:main Oct 19, 2021
@vstinner vstinner deleted the capi_compat branch October 19, 2021 10:10
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.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.