8000 bpo-45434: Limited Python.h no longer includes stdio.h by vstinner · Pull Request #28960 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-45434: Limited Python.h no longer includes stdio.h #28960

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

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ Porting to Python 3.11
``exit()`` and ``abort()``.
(Contributed by Victor Stinner in :issue:`45434`.)

* The ``<Python.h>`` header file no longer includes ``<stdio.h>`` if the
``Py_LIMITED_API`` macro is defined. Functions expecting ``FILE*`` are
excluded from the limited C API (:pep:`384`). C extensions using
``<stdio.h>`` must now include it explicitly. The system ``<stdio.h>``
header provides functions like ``printf()`` and ``fopen()``.
(Contributed by Victor Stinner in :issue:`45434`.)

Deprecated
----------

Expand Down
11 changes: 4 additions & 7 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
# define _SGI_MP_SOURCE
#endif

#include <stdio.h> // NULL, FILE*
#ifndef NULL
# error "Python.h requires that stdio.h define NULL."
#endif

#include <string.h> // memcpy()
#ifndef Py_LIMITED_API
# include <stdio.h> // FILE*
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h> // errno
#endif
#ifndef MS_WINDOWS
# include <unistd.h>
#endif
#ifdef HAVE_STDDEF_H
// For size_t
# include <stddef.h>
# include <stddef.h> // size_t
#endif

#include <assert.h> // assert()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The ``<Python.h>`` header file no longer includes ``<stdio.h>`` if the
``Py_LIMITED_API`` macro is defined. Functions expecting ``FILE*`` are excluded
from the limited C API (:pep:`384`). C extensions using ``<stdio.h>`` must now
include it explicitly.
Patch by Victor Stinner.
0