summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-17 21:54:00 (GMT)
committerGitHub <noreply@github.com>2019-05-17 21:54:00 (GMT)
commit871ff77c1cd334a141d52b0d003c080a1928731e (patch)
tree0c7c37e1d28f52fc8967bc3d85da5bb68a13fa8a /Include/cpython
parent12083284c54be25abadd85781d36b63731dc1f0c (diff)
downloadcpython-871ff77c1cd334a141d52b0d003c080a1928731e.zip
cpython-871ff77c1cd334a141d52b0d003c080a1928731e.tar.gz
cpython-871ff77c1cd334a141d52b0d003c080a1928731e.tar.bz2
bpo-36763: Add _PyInitError functions (GH-13395)
* Add _PyInitError functions: * _PyInitError_Ok() * _PyInitError_Error() * _PyInitError_NoMemory() * _PyInitError_Exit() * _PyInitError_IsError() * _PyInitError_IsExit() * _PyInitError_Failed() * frozenmain.c and _testembed.c now use functions rather than macros. * Move _Py_INIT_xxx() macros to the internal API. * Move _PyWstrList_INIT macro to the internal API.
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/coreconfig.h37
1 files changed, 7 insertions, 30 deletions
diff --git a/Include/cpython/coreconfig.h b/Include/cpython/coreconfig.h
index 73861a9..f05edda 100644
--- a/Include/cpython/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -18,34 +18,13 @@ typedef struct {
int exitcode;
} _PyInitError;
-/* Almost all errors causing Python initialization to fail */
-#ifdef _MSC_VER
- /* Visual Studio 2015 doesn't implement C99 __func__ in C */
-# define _Py_INIT_GET_FUNC() __FUNCTION__
-#else
-# define _Py_INIT_GET_FUNC() __func__
-#endif
-
-#define _Py_INIT_OK() \
- (_PyInitError){._type = _Py_INIT_ERR_TYPE_OK,}
- /* other fields are set to 0 */
-#define _Py_INIT_ERR(ERR_MSG) \
- (_PyInitError){ \
- ._type = _Py_INIT_ERR_TYPE_ERROR, \
- ._func = _Py_INIT_GET_FUNC(), \
- .err_msg = (ERR_MSG)}
- /* other fields are set to 0 */
-#define _Py_INIT_NO_MEMORY() _Py_INIT_ERR("memory allocation failed")
-#define _Py_INIT_EXIT(EXITCODE) \
- (_PyInitError){ \
- ._type = _Py_INIT_ERR_TYPE_EXIT, \
- .exitcode = (EXITCODE)}
-#define _Py_INIT_IS_ERROR(err) \
- (err._type == _Py_INIT_ERR_TYPE_ERROR)
-#define _Py_INIT_IS_EXIT(err) \
- (err._type == _Py_INIT_ERR_TYPE_EXIT)
-#define _Py_INIT_FAILED(err) \
- (err._type != _Py_INIT_ERR_TYPE_OK)
+PyAPI_FUNC(_PyInitError) _PyInitError_Ok(void);
+PyAPI_FUNC(_PyInitError) _PyInitError_Error(const char *err_msg);
+PyAPI_FUNC(_PyInitError) _PyInitError_NoMemory(void);
+PyAPI_FUNC(_PyInitError) _PyInitError_Exit(int exitcode);
+PyAPI_FUNC(int) _PyInitError_IsError(_PyInitError err);
+PyAPI_FUNC(int) _PyInitError_IsExit(_PyInitError err);
+PyAPI_FUNC(int) _PyInitError_Failed(_PyInitError err);
/* --- _PyWstrList ------------------------------------------------ */
@@ -56,8 +35,6 @@ typedef struct {
wchar_t **items;
} _PyWstrList;
-#define _PyWstrList_INIT (_PyWstrList){.length = 0, .items = NULL}
-
/* --- _PyPreConfig ----------------------------------------------- */