-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-112026: Add again <unistd.h> include in Python.h #112046
Conversation
Add again <ctype.h> and <unistd.h> includes in Python.h, but don't include them in the limited C API version 3.13 and newer.
The removal of <ctype.h> and <unistd.h> header files impacted many projects: https://discuss.python.org/t/ongoing-packages-rebuild-with-python-3-13-in-fedora/38134
|
|
The commit 03c4080 also removed a workaround on macOS ( |
-1 on this. It is not Python's job to include system headers that are not used by Python's own header files. Let third-party authors fix their own code. |
In issue gh-108765, I modified Python.h to removed multiple "standard" header files from
These changes are documented in What's New in Python 3.13 and I know that multiple projects have already been updated to include these header explicitly. My colleague Karolina didn't ask for revert, she only listed projects impacted by Python 3.13 incompatible C API changes. Since I did these changes, obviously, I'm supportive of these changes, but I'm questioning if Python 3.13 is the right time to make these changes. We can make them again in Python 3.14. Also, I'm thinking about a new way to introduce incompatible changes which are not "mandatory" to have a smoother migration plan than "affect everybody at once". |
Perhaps there's a middle ground:
This means we don't have to maintain this forever, but also lets projects fix themselves on a longer timeline, and avoids potentially disrupting all the other large work in 3.13. |
We did that multiple times in the past and it went well:
For these examples, the change was done again in the following Python version |
Yeah, I'm okay with using alpha releases as "scream tests" (as we call them at work) - make the change, find out who screams, revert the change and let those people know how long they've got until it becomes permanent. Add a comment saying that these should be removed in 3.14.0a1 and I'm fine. |
I can't speak on the #112046 (comment) bit because that's a CPython decision, but I will say from the distribution perspective, we're very used to having various transitive include issues with new compiler versions, new libc versions, and new library versions. This wouldn't be that different for us and is fine. Given this was introduced pretty early in the cycle, I'm a little surprised at it bothering anybody. |
Seconded. The reason why downstream projects might feel a compelling desire to have CPython APIs reverted is because use of private APIs is standardly done for reasons of "I feel I have no choice" and people are correct for using private APIs if they ended up using them. Sure, use of private APIs means that you're accepting the responsibility of depending on something that isn't guaranteed to exist in the future, and that might mean a hard time if CPython decides to remove them for whatever reason, but at the time you started using that private API, it wasn't a bug that you decided to use the private API. Failing to include a required header because your other includes transitively included that header, is a bug. You wrote incorrect code, it was always wrong, you just didn't happen to notice. Every dependency you possess might be hiding transitive includes. Even the compiler regularly documents such issues in "porting to XXX". The solution is adding the header that you always needed. There are tools to automate this, such as include-what-you-use. Either way, adding that header is semantically correct for all old versions of python as well. Fixing use of private API may often mean ifdef'ing code for different versions of the CPython API, or dropping support for some versions of CPython, or not having any good solution at all and becoming much slower, and that's the main reason people might want a grace period for private API. I'd be interested to hear if there's any project with missing unistd.h includes that, faced with a bug report on python 3.13, doesn't just... add the include in a heartbeat. Unless the project is entirely dead upstream, of course. :) |
I agree with that in general. This is a trivial issue, it affects surprisingly many projects -> let's revert and then discuss. |
I think that there are two valid use cases:
Currently, we only have a single big hammer button: change the main branch and affect everybody right now. IMO we need a different approach to satisfy both groups: let developers eager to make their code "future proof" and fix "tidy" issues right now, and give time to other busy maintainers who are already dealing with the long list of other Python 3.13 incompatible changes. Such solution is being discussed there:
The Phase 2 of my "Clarify private vs public functions in Python 3.13" plan required to make "most popular projects like Cython, numpy and pip" compatible in Python 3.13 alpha 1 release. Well, this target release/date was missed, but we can now target the next alpha2 scheduled next Tuesday. I'm actively working on fixing numpy since it blocks my collleagues who are upgrading Python from 3.12 to 3.13 in Fedora 40: https://discuss.python.org/t/ongoing-packages-rebuild-with-python-3-13-in-fedora/38134 Until numpy is fixed, they are hundreds of Python packages which cannot be tested, and so we may miss many bugs. I would prefer to get bug reports as soon as possible to have more time to fix them. Previously, it was discussed to introduce such "tidy" changes in alpha1 version. Once affected projects are aware, revert the change to give more time to maintainers to update their code. Well, I think that it is exactly what was done in Python 3.13 alpha1. I was asked by my colleague Miro to batch all incompatible changes in alpha1 but then don't make further changes before Python 3.14. I did exactly that :-) That's why I removed all deprecated functions scheduled for removal in Python 3.13 at once. So now we can consider to restore them if needed. |
If people are interested to "tidy" Python C API, I suggest discussing solutions which would have a smoother migration path in capi-workgroup/api-evolution#24 Thanks for the interesting discussion and feedback. |
Add again <ctype.h> and <unistd.h> includes in Python.h, but don't include them in the limited C API version 3.13 and newer.
📚 Documentation preview 📚: https://cpython-previews--112046.org.readthedocs.build/