[Python-checkins] closes bpo-44751: Move crypt.h include from public header to _cryptmodule (GH-27394) (GH-28636)

vstinner webhook-mailer at python.org
Wed Sep 29 19:02:16 EDT 2021

commit: 80285ecc8deaa2b0e7351bf4be863d1a0ad3c188
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2021-09-30T01:02:11+02:00

closes bpo-44751: Move crypt.h include from public header to _cryptmodule (GH-27394) (GH-28636)

Automerge-Triggered-By: GH:benjaminp
(cherry picked from commit 196998e220d6ca030e5a1c8ad63fcaed8e049a98)

Co-authored-by: Geoffrey Thomas <geofft at ldpreload.com>

A Misc/NEWS.d/next/C API/2021-07-27-17-29-12.bpo-44751.4qmbDG.rst
M Include/Python.h
M Modules/_cryptmodule.c

diff --git a/Include/Python.h b/Include/Python.h
index 04858f281cab8..a83befa311736 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -35,19 +35,6 @@
 #ifndef MS_WINDOWS
 #include <unistd.h>
-#ifdef HAVE_CRYPT_H
-#if defined(HAVE_CRYPT_R) && !defined(_GNU_SOURCE)
-/* Required for glibc to expose the crypt_r() function prototype. */
-#  define _GNU_SOURCE
-#include <crypt.h>
-/* Don't leak the _GNU_SOURCE define to other headers. */
-#  undef _GNU_SOURCE
 /* For size_t? */
diff --git a/Misc/NEWS.d/next/C API/2021-07-27-17-29-12.bpo-44751.4qmbDG.rst b/Misc/NEWS.d/next/C API/2021-07-27-17-29-12.bpo-44751.4qmbDG.rst
new file mode 100644
index 0000000000000..d7b9f09819669
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-07-27-17-29-12.bpo-44751.4qmbDG.rst	
@@ -0,0 +1 @@
+Remove ``crypt.h`` include from the public ``Python.h`` header.
diff --git a/Modules/_cryptmodule.c b/Modules/_cryptmodule.c
index a95f55a63c306..72a4f44600d92 100644
--- a/Modules/_cryptmodule.c
+++ b/Modules/_cryptmodule.c
@@ -4,6 +4,9 @@
 #include "Python.h"
 #include <sys/types.h>
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
 /* Module crypt */

More information about the Python-checkins mailing list