Skip to content

Commit

Permalink
pythongh-108765: Python.h no longer includes <sys/time.h>
Browse files Browse the repository at this point in the history
Python.h no longer includes these standard header files: <time.h>,
<sys/select.h> and <sys/time.h>. They should now be included
explicitly if needed.
  • Loading branch information
vstinner committed Sep 1, 2023
1 parent 03c5a68 commit 26cf3e5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ New Features
Porting to Python 3.13
----------------------

* ``Python.h`` no longer includes these standard header files: ``<time.h>``,
``<sys/select.h>`` and ``<sys/time.h>``. They should now be included
explicitly if needed.
(Contributed by Victor Stinner in :gh:`108765`.)

Deprecated
----------

Expand Down
19 changes: 0 additions & 19 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,6 @@ typedef Py_ssize_t Py_ssize_clean_t;

#include <math.h> /* Moved here from the math section, before extern "C" */

/********************************************
* WRAPPER FOR <time.h> and/or <sys/time.h> *
********************************************/

#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>

/******************************
* WRAPPER FOR <sys/select.h> *
******************************/

/* NB caller must include <sys/types.h> */

#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif /* !HAVE_SYS_SELECT_H */

/*******************************
* stat() and fstat() fiddling *
*******************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``Python.h`` no longer includes these standard header files: ``<time.h>``,
``<sys/select.h>`` and ``<sys/time.h>``. They should now be included
explicitly if needed. Patch by Victor Stinner.
4 changes: 4 additions & 0 deletions Modules/_multiprocessing/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include "multiprocessing.h"

#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> // gettimeofday()
#endif

#ifdef HAVE_MP_SEMAPHORE

enum { RECURSIVE_MUTEX, SEMAPHORE };
Expand Down
4 changes: 4 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@

#include <stdio.h> // ctermid()
#include <stdlib.h> // system()
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> // futimes()
#endif


/*
* A number of APIs are available on macOS from a certain macOS version.
Expand Down

0 comments on commit 26cf3e5

Please sign in to comment.