Skip to content
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
2 changes: 1 addition & 1 deletion Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#include "codecs.h"
#include "pyerrors.h"

#include "coreconfig.h"
#include "cpython/coreconfig.h"
#include "pystate.h"
#include "context.h"

Expand Down
30 changes: 5 additions & 25 deletions Include/coreconfig.h → Include/cpython/coreconfig.h
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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. */
Expand Down Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions Include/internal/pycore_coreconfig.h
Original file line number Diff line number Diff line change
@@ -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 */
1 change: 0 additions & 1 deletion Include/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand Down
3 changes: 2 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down
7 changes: 5 additions & 2 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions Python/coreconfig.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Python.h"
#include "pycore_coreconfig.h"
#include "pycore_fileutils.h"
#include "pycore_pylifecycle.h"
#include "pycore_pymem.h"
Expand Down
1 change: 1 addition & 0 deletions Python/pathconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down