Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

gh-108765: Python.h no longer includes <unistd.h>#108783

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:remove_unistd_h
Sep 2, 2023

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedSep 1, 2023
edited by github-actionsbot
Loading

@vstinnervstinner marked this pull request as ready for reviewSeptember 2, 2023 14:11
@vstinnervstinner merged commit594b000 intopython:mainSep 2, 2023
@vstinnervstinner deleted the remove_unistd_h branchSeptember 2, 2023 14:50
@vstinner
Copy link
MemberAuthor

I merged my PR.

If it causes too many trouble in 3rd party C extensions (require to update too many C extensions before Python 3.13 beta1), I can make this change conditional only in the limited C API version 3.13, as I did for other headers inPython.h:

// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by Python// headers, but kept for backward compatibility (no introduce new compiler// warnings). They are not included by the limited C API version 3.11 and// above.#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000#  include <errno.h>              // errno#  include <stdio.h>              // FILE*#  include <stdlib.h>             // getenv()#  include <string.h>             // memcpy()#endif

I consider that<unistd.h> is less commonly used by than the very common<errno.h>,<stdio.h>,<stdlib.h> and<string.h>. Again, if it causes too much burden, I can make the change conditional.

gpshead reacted with thumbs up emoji

@jibal
Copy link

breaks signalmodule.c

@vstinner
Copy link
MemberAuthor

breaks signalmodule.c

Would you mind to elaborate your comment "a little bit"? What is broken? Is it a build issue? On which Python version? On which OS (name, version) and compiler (name, version)?

@jibal
Copy link

signalmodule.c calls pause() and alarm() (under #ifdef HAVE_{PAUSE,ALARM} guards), which are defined in unistd.h

On the Python version where you deleted unistd.h from Python.h, of course.

@vstinner
Copy link
MemberAuthor

signalmodule.c calls pause() and alarm() (under #ifdef HAVE_{PAUSE,ALARM} guards), which are defined in unistd.h

Hum, in fact, <unistd.h> is included indirectly by pycore_pythread.h. But well, I wrote PR#111402 to make it extra clear.

@jibal
Copy link

jibal commentedOct 27, 2023
edited
Loading

Hum, in fact, <unistd.h> is included indirectly by pycore_pythread.h.

Which is not necessarily included when signalmodule.c is compiled ... it wasn't in my build. (Which I've abandoned ... I never actually intended to build the top of tree.)

But well, I wrote PR#111402 to make it extra clear.

Seems like the right thing to do.

@vstinner
Copy link
MemberAuthor

Which is not necessarily included when signalmodule.c is compiled ... it wasn't in my build. (Which I've abandoned ... I never actually intended to build the top of tree.)

You didn't reply to my question about OS and compiler... Also, pycore_pythread.h was modified recently.

rathann added a commit to rathann/python-zstandard that referenced this pull requestNov 25, 2023
This fixes the following compilation error with Python 3.13.0a1:```c-ext/backend_c.c:275:13: error: implicit declaration of function ‘sysconf’; did you mean ‘sscanf’? [-Werror=implicit-function-declaration]  275 |     count = sysconf(_SC_NPROCESSORS_ONLN);      |             ^~~~~~~      |             sscanf```According tohttps://docs.python.org/3.13/whatsnew/3.13.html:Python.h no longer includes the <unistd.h> standard header file.If needed, it should now be included explicitly.For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize().As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h.The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.Seepython/cpython#108783 .
rathann added a commit to rathann/python-zstandard that referenced this pull requestMar 28, 2025
This fixes the following compilation error with Python 3.13.0a1:```c-ext/backend_c.c:275:13: error: implicit declaration of function ‘sysconf’; did you mean ‘sscanf’? [-Werror=implicit-function-declaration]  275 |     count = sysconf(_SC_NPROCESSORS_ONLN);      |             ^~~~~~~      |             sscanf```According tohttps://docs.python.org/3.13/whatsnew/3.13.html:Python.h no longer includes the <unistd.h> standard header file.If needed, it should now be included explicitly.For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize().As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h.The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.Seepython/cpython#108783 .
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@vstinner@jibal@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp