aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-01 03:44:13 +0100
committerGitHub <noreply@github.com>2019-03-01 03:44:13 +0100
commitf684d83d86e1990784816d4b243d724e6ab8304f (patch)
tree14d2a51e9bd7751ab89cf21363519d19e3970b28
parentab71f8b793f7b42853ccd2a127ae7720adc5bcb4 (diff)
downloadcpython3-f684d83d86e1990784816d4b243d724e6ab8304f.tar.gz
bpo-36142: Exclude coreconfig.h from Py_LIMITED_API (GH-12111)
The whole coreconfig.h header is now excluded from Py_LIMITED_API. Move functions definitions into a new internal pycore_coreconfig.h header. * Move Include/coreconfig.h to Include/cpython/coreconfig.h * coreconfig.h header is now excluded from Py_LIMITED_API * Move functions to pycore_coreconfig.h
-rw-r--r--Include/Python.h2
-rw-r--r--Include/cpython/coreconfig.h (renamed from Include/coreconfig.h)30
-rw-r--r--Include/cpython/pystate.h2
-rw-r--r--Include/internal/pycore_coreconfig.h33
-rw-r--r--Include/pystate.h1
-rw-r--r--Makefile.pre.in3
-rw-r--r--Misc/NEWS.d/next/C API/2019-03-01-03-23-48.bpo-36142.7F6wJd.rst2
-rw-r--r--Modules/main.c1
-rw-r--r--PCbuild/pythoncore.vcxproj3
-rw-r--r--PCbuild/pythoncore.vcxproj.filters7
-rw-r--r--Python/coreconfig.c1
-rw-r--r--Python/pathconfig.c1
-rw-r--r--Python/pylifecycle.c1
-rw-r--r--Python/pystate.c1
14 files changed, 57 insertions, 31 deletions
diff --git a/Include/Python.h b/Include/Python.h
index aa60175f52..55b06aeea9 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -128,7 +128,7 @@
#include "codecs.h"
#include "pyerrors.h"
-#include "coreconfig.h"
+#include "cpython/coreconfig.h"
#include "pystate.h"
#include "context.h"
diff --git a/Include/coreconfig.h b/Include/cpython/coreconfig.h
index 0ed3222a15..f7ac3f9cff 100644
--- a/Include/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -1,11 +1,12 @@
#ifndef Py_PYCORECONFIG_H
#define Py_PYCORECONFIG_H
+#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif
+/* _PyInitError */
-#ifndef Py_LIMITED_API
typedef struct {
const char *prefix;
const char *msg;
@@ -32,8 +33,7 @@ typedef struct {
#define _Py_INIT_FAILED(err) \
(err.msg != NULL)
-#endif /* !defined(Py_LIMITED_API) */
-
+/* _PyCoreConfig */
typedef struct {
/* Install signal handlers? Yes by default. */
@@ -339,32 +339,12 @@ typedef struct {
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
-PyAPI_FUNC(int) _PyCoreConfig_Copy(
- _PyCoreConfig *config,
- const _PyCoreConfig *config2);
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
- const _PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);
-PyAPI_FUNC(const char*) _PyCoreConfig_GetEnv(
- const _PyCoreConfig *config,
- const char *name);
-PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
- const _PyCoreConfig *config,
- wchar_t **dest,
- wchar_t *wname,
- char *name);
-
-/* Used by _testcapi.get_global_config() and _testcapi.get_core_config() */
+/* Functions used for testing */
PyAPI_FUNC(PyObject *) _Py_GetGlobalVariablesAsDict(void);
PyAPI_FUNC(PyObject *) _PyCoreConfig_AsDict(const _PyCoreConfig *config);
-#endif
#ifdef __cplusplus
}
#endif
+#endif /* !Py_LIMITED_API */
#endif /* !Py_PYCORECONFIG_H */
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 0da59d96d1..3fca78f9dd 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -6,6 +6,8 @@
extern "C" {
#endif
+#include "cpython/coreconfig.h"
+
/* Placeholders while working on the new configuration API
*
* See PEP 432 for final anticipated contents
diff --git a/Include/internal/pycore_coreconfig.h b/Include/internal/pycore_coreconfig.h
new file mode 100644
index 0000000000..b906ac4f7f
--- /dev/null
+++ b/Include/internal/pycore_coreconfig.h
@@ -0,0 +1,33 @@
+#ifndef Py_INTERNAL_CORECONFIG_H
+#define Py_INTERNAL_CORECONFIG_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
+#endif
+
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
+PyAPI_FUNC(int) _PyCoreConfig_Copy(
+ _PyCoreConfig *config,
+ const _PyCoreConfig *config2);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
+ const _PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);
+PyAPI_FUNC(const char*) _PyCoreConfig_GetEnv(
+ const _PyCoreConfig *config,
+ const char *name);
+PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
+ const _PyCoreConfig *config,
+ wchar_t **dest,
+ wchar_t *wname,
+ char *name);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_CORECONFIG_H */
diff --git a/Include/pystate.h b/Include/pystate.h
index a541dc8f00..a79a2e60e2 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -8,7 +8,6 @@ extern "C" {
#endif
#include "pythread.h"
-#include "coreconfig.h"
/* This limitation is for performance and simplicity. If needed it can be
removed (with effort). */
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 1c536f813f..9c2d3d66a0 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -994,7 +994,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/codecs.h \
$(srcdir)/Include/compile.h \
$(srcdir)/Include/complexobject.h \
- $(srcdir)/Include/coreconfig.h \
$(srcdir)/Include/descrobject.h \
$(srcdir)/Include/dictobject.h \
$(srcdir)/Include/dtoa.h \
@@ -1071,6 +1070,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/Python-ast.h \
\
$(srcdir)/Include/cpython/abstract.h \
+ $(srcdir)/Include/cpython/coreconfig.h \
$(srcdir)/Include/cpython/dictobject.h \
$(srcdir)/Include/cpython/object.h \
$(srcdir)/Include/cpython/objimpl.h \
@@ -1085,6 +1085,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_ceval.h \
$(srcdir)/Include/internal/pycore_condvar.h \
$(srcdir)/Include/internal/pycore_context.h \
+ $(srcdir)/Include/internal/pycore_coreconfig.h \
$(srcdir)/Include/internal/pycore_fileutils.h \
$(srcdir)/Include/internal/pycore_getopt.h \
$(srcdir)/Include/internal/pycore_gil.h \
diff --git a/Misc/NEWS.d/next/C API/2019-03-01-03-23-48.bpo-36142.7F6wJd.rst b/Misc/NEWS.d/next/C API/2019-03-01-03-23-48.bpo-36142.7F6wJd.rst
new file mode 100644
index 0000000000..0005270c22
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2019-03-01-03-23-48.bpo-36142.7F6wJd.rst
@@ -0,0 +1,2 @@
+The whole coreconfig.h header is now excluded from Py_LIMITED_API. Move
+functions definitions into a new internal pycore_coreconfig.h header.
diff --git a/Modules/main.c b/Modules/main.c
index f6e7889008..f373dab208 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -2,6 +2,7 @@
#include "Python.h"
#include "osdefs.h"
+#include "pycore_coreconfig.h"
#include "pycore_getopt.h"
#include "pycore_pathconfig.h"
#include "pycore_pylifecycle.h"
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index b1b9944d1e..1ec5f75808 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -110,8 +110,8 @@
<ClInclude Include="..\Include\compile.h" />
<ClInclude Include="..\Include\complexobject.h" />
<ClInclude Include="..\Include\context.h" />
- <ClInclude Include="..\Include\coreconfig.h" />
<ClInclude Include="..\Include\cpython\abstract.h" />
+ <ClInclude Include="..\Include\cpython\coreconfig.h" />
<ClInclude Include="..\Include\cpython\dictobject.h" />
<ClInclude Include="..\Include\cpython\object.h" />
<ClInclude Include="..\Include\cpython\objimpl.h" />
@@ -141,6 +141,7 @@
<ClInclude Include="..\Include\internal\pycore_ceval.h" />
<ClInclude Include="..\Include\internal\pycore_condvar.h" />
<ClInclude Include="..\Include\internal\pycore_context.h" />
+ <ClInclude Include="..\Include\internal\pycore_coreconfig.h" />
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
<ClInclude Include="..\Include\internal\pycore_gil.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 9dbd0669f7..5053dcf1e8 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -81,10 +81,10 @@
<ClInclude Include="..\Include\context.h">
<Filter>Include</Filter>
</ClInclude>
- <ClInclude Include="..\Include\coreconfig.h">
+ <ClInclude Include="..\Include\cpython\abstract.h">
<Filter>Include</Filter>
</ClInclude>
- <ClInclude Include="..\Include\cpython\abstract.h">
+ <ClInclude Include="..\Include\cpython\coreconfig.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\dictobject.h">
@@ -174,6 +174,9 @@
<ClInclude Include="..\Include\internal\pycore_context.h">
<Filter>Include</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\internal\pycore_coreconfig.h">
+ <Filter>Include</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\internal\pycore_fileutils.h">
<Filter>Include</Filter>
</ClInclude>
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index 2fb4e3fd19..06dbada6df 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1,4 +1,5 @@
#include "Python.h"
+#include "pycore_coreconfig.h"
#include "pycore_fileutils.h"
#include "pycore_pylifecycle.h"
#include "pycore_pymem.h"
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index c9bddcf6c6..eadc09baa9 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -2,6 +2,7 @@
#include "Python.h"
#include "osdefs.h"
+#include "pycore_coreconfig.h"
#include "pycore_fileutils.h"
#include "pycore_pathconfig.h"
#include "pycore_pymem.h"
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index eb0fdddb4b..1d65d3b86f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -4,6 +4,7 @@
#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_coreconfig.h"
#include "pycore_context.h"
#include "pycore_fileutils.h"
#include "pycore_hamt.h"
diff --git a/Python/pystate.c b/Python/pystate.c
index 6fe947d364..a9a425c2f4 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2,6 +2,7 @@
/* Thread and interpreter state structures and their interfaces */
#include "Python.h"
+#include "pycore_coreconfig.h"
#include "pycore_pymem.h"
#include "pycore_pystate.h"