From e5024517811ee990b770fca0ba7058742d00e032 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 12 Sep 2018 12:06:42 -0700 Subject: [PATCH] closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218) --- Modules/_hashopenssl.c | 2 +- Modules/_io/winconsoleio.c | 2 +- Modules/posixmodule.c | 4 ++-- Objects/methodobject.c | 2 +- Objects/object.c | 2 +- Parser/printgrammar.c | 2 +- Python/_warnings.c | 2 +- Python/compile.c | 2 +- Python/graminit.c | 2 +- Python/import.c | 2 +- Python/pystrhex.c | 6 ++++-- Python/pystrtod.c | 4 ++-- Python/pythonrun.c | 32 ++++++++++++++++---------------- 13 files changed, 33 insertions(+), 31 deletions(-) diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 40cd632731..7121224e2f 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -245,7 +245,7 @@ EVP_hexdigest(EVPobject *self, PyObject *unused) EVP_MD_CTX_free(temp_ctx); - return _Py_strhex((const char *)digest, digest_size); + return _Py_strhex((const char *)digest, (Py_ssize_t)digest_size); } PyDoc_STRVAR(EVP_update__doc__, diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index f08406643f..13342ec239 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -1170,6 +1170,6 @@ PyTypeObject PyWindowsConsoleIO_Type = { 0, /* tp_finalize */ }; -PyAPI_DATA(PyObject *) _PyWindowsConsoleIO_Type = (PyObject*)&PyWindowsConsoleIO_Type; +PyObject * _PyWindowsConsoleIO_Type = (PyObject*)&PyWindowsConsoleIO_Type; #endif /* MS_WINDOWS */ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index c5d9a17b00..48bd5dc394 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -488,8 +488,8 @@ PyOS_AfterFork(void) #ifdef MS_WINDOWS /* defined in fileutils.c */ -PyAPI_FUNC(void) _Py_time_t_to_FILE_TIME(time_t, int, FILETIME *); -PyAPI_FUNC(void) _Py_attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *, +void _Py_time_t_to_FILE_TIME(time_t, int, FILETIME *); +void _Py_attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *, ULONG, struct _Py_stat_struct *); #endif diff --git a/Objects/methodobject.c b/Objects/methodobject.c index a7042ca39e..5ad283104f 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -18,7 +18,7 @@ static int numfree = 0; /* undefine macro trampoline to PyCFunction_NewEx */ #undef PyCFunction_New -PyAPI_FUNC(PyObject *) +PyObject * PyCFunction_New(PyMethodDef *ml, PyObject *self) { return PyCFunction_NewEx(ml, self, NULL); diff --git a/Objects/object.c b/Objects/object.c index 6498756c92..607f047d14 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2180,7 +2180,7 @@ _PyTrash_thread_destroy_chain(void) /* For Py_LIMITED_API, we need an out-of-line version of _Py_Dealloc. Define this here, so we can undefine the macro. */ #undef _Py_Dealloc -PyAPI_FUNC(void) _Py_Dealloc(PyObject *); +void _Py_Dealloc(PyObject *); void _Py_Dealloc(PyObject *op) { diff --git a/Parser/printgrammar.c b/Parser/printgrammar.c index 7311e55170..1a8b0e176f 100644 --- a/Parser/printgrammar.c +++ b/Parser/printgrammar.c @@ -18,7 +18,7 @@ printgrammar(grammar *g, FILE *fp) fprintf(fp, "/* Generated by Parser/pgen */\n\n"); fprintf(fp, "#include \"pgenheaders.h\"\n"); fprintf(fp, "#include \"grammar.h\"\n"); - fprintf(fp, "PyAPI_DATA(grammar) _PyParser_Grammar;\n"); + fprintf(fp, "grammar _PyParser_Grammar;\n"); printdfas(g, fp); printlabels(g, fp); fprintf(fp, "grammar _PyParser_Grammar = {\n"); diff --git a/Python/_warnings.c b/Python/_warnings.c index 2229206b25..8e1c01d0b2 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1004,7 +1004,7 @@ PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level) #undef PyErr_Warn -PyAPI_FUNC(int) +int PyErr_Warn(PyObject *category, const char *text) { return PyErr_WarnEx(category, text, 1); diff --git a/Python/compile.c b/Python/compile.c index 3528670ef6..c6a667c29e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5550,7 +5550,7 @@ assemble(struct compiler *c, int addNone) } #undef PyAST_Compile -PyAPI_FUNC(PyCodeObject *) +PyCodeObject * PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags, PyArena *arena) { diff --git a/Python/graminit.c b/Python/graminit.c index 8e89ccea3b..5770e8f6a9 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -2,7 +2,7 @@ #include "pgenheaders.h" #include "grammar.h" -PyAPI_DATA(grammar) _PyParser_Grammar; +grammar _PyParser_Grammar; static arc arcs_0_0[3] = { {2, 1}, {3, 1}, diff --git a/Python/import.c b/Python/import.c index 319b661f1f..2a9a576658 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1138,7 +1138,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, return importer; } -PyAPI_FUNC(PyObject *) +PyObject * PyImport_GetImporter(PyObject *path) { PyObject *importer=NULL, *path_importer_cache=NULL, *path_hooks=NULL; diff --git a/Python/pystrhex.c b/Python/pystrhex.c index 6dbf32dcc4..028f187c70 100644 --- a/Python/pystrhex.c +++ b/Python/pystrhex.c @@ -2,6 +2,8 @@ #include "Python.h" +#include "pystrhex.h" + static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen, int return_bytes) { @@ -48,14 +50,14 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen, return retval; } -PyAPI_FUNC(PyObject *) _Py_strhex(const char* argbuf, const Py_ssize_t arglen) +PyObject * _Py_strhex(const char* argbuf, const Py_ssize_t arglen) { return _Py_strhex_impl(argbuf, arglen, 0); } /* Same as above but returns a bytes() instead of str() to avoid the * need to decode the str() when bytes are needed. */ -PyAPI_FUNC(PyObject *) _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen) +PyObject * _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen) { return _Py_strhex_impl(argbuf, arglen, 1); } diff --git a/Python/pystrtod.c b/Python/pystrtod.c index 461e8dcb5e..98aa9ba48b 100644 --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -791,7 +791,7 @@ _PyOS_ascii_formatd(char *buffer, /* The fallback code to use if _Py_dg_dtoa is not available. */ -PyAPI_FUNC(char *) PyOS_double_to_string(double val, +char * PyOS_double_to_string(double val, char format_code, int precision, int flags, @@ -1238,7 +1238,7 @@ format_float_short(double d, char format_code, } -PyAPI_FUNC(char *) PyOS_double_to_string(double val, +char * PyOS_double_to_string(double val, char format_code, int precision, int flags, diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 273eae25e2..43a98c96cd 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1492,56 +1492,56 @@ PyOS_CheckStack(void) /* Deprecated C API functions still provided for binary compatibility */ #undef PyParser_SimpleParseFile -PyAPI_FUNC(node *) +node * PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) { return PyParser_SimpleParseFileFlags(fp, filename, start, 0); } #undef PyParser_SimpleParseString -PyAPI_FUNC(node *) +node * PyParser_SimpleParseString(const char *str, int start) { return PyParser_SimpleParseStringFlags(str, start, 0); } #undef PyRun_AnyFile -PyAPI_FUNC(int) +int PyRun_AnyFile(FILE *fp, const char *name) { return PyRun_AnyFileExFlags(fp, name, 0, NULL); } #undef PyRun_AnyFileEx -PyAPI_FUNC(int) +int PyRun_AnyFileEx(FILE *fp, const char *name, int closeit) { return PyRun_AnyFileExFlags(fp, name, closeit, NULL); } #undef PyRun_AnyFileFlags -PyAPI_FUNC(int) +int PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags) { return PyRun_AnyFileExFlags(fp, name, 0, flags); } #undef PyRun_File -PyAPI_FUNC(PyObject *) +PyObject * PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l) { return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL); } #undef PyRun_FileEx -PyAPI_FUNC(PyObject *) +PyObject * PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c) { return PyRun_FileExFlags(fp, p, s, g, l, c, NULL); } #undef PyRun_FileFlags -PyAPI_FUNC(PyObject *) +PyObject * PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags) { @@ -1549,14 +1549,14 @@ PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, } #undef PyRun_SimpleFile -PyAPI_FUNC(int) +int PyRun_SimpleFile(FILE *f, const char *p) { return PyRun_SimpleFileExFlags(f, p, 0, NULL); } #undef PyRun_SimpleFileEx -PyAPI_FUNC(int) +int PyRun_SimpleFileEx(FILE *f, const char *p, int c) { return PyRun_SimpleFileExFlags(f, p, c, NULL); @@ -1564,28 +1564,28 @@ PyRun_SimpleFileEx(FILE *f, const char *p, int c) #undef PyRun_String -PyAPI_FUNC(PyObject *) +PyObject * PyRun_String(const char *str, int s, PyObject *g, PyObject *l) { return PyRun_StringFlags(str, s, g, l, NULL); } #undef PyRun_SimpleString -PyAPI_FUNC(int) +int PyRun_SimpleString(const char *s) { return PyRun_SimpleStringFlags(s, NULL); } #undef Py_CompileString -PyAPI_FUNC(PyObject *) +PyObject * Py_CompileString(const char *str, const char *p, int s) { return Py_CompileStringExFlags(str, p, s, NULL, -1); } #undef Py_CompileStringFlags -PyAPI_FUNC(PyObject *) +PyObject * Py_CompileStringFlags(const char *str, const char *p, int s, PyCompilerFlags *flags) { @@ -1593,14 +1593,14 @@ Py_CompileStringFlags(const char *str, const char *p, int s, } #undef PyRun_InteractiveOne -PyAPI_FUNC(int) +int PyRun_InteractiveOne(FILE *f, const char *p) { return PyRun_InteractiveOneFlags(f, p, NULL); } #undef PyRun_InteractiveLoop -PyAPI_FUNC(int) +int PyRun_InteractiveLoop(FILE *f, const char *p) { return PyRun_InteractiveLoopFlags(f, p, NULL); -- 2.40.0