From 9402bb9099c7a755777513a31d7674ab24cc22bb Mon Sep 17 00:00:00 2001 From: Paul Barrett Date: Wed, 27 Nov 2024 16:47:30 -0600 Subject: [PATCH] Add declarations for private functions from pycore_modsupport https://github.com/python/cpython/issues/110964 Copied from pycore_modsupport.h remove PY_SSIZE_T_CLEAN definition https://github.com/python/cpython/issues/104922 --- py313/_curses_panel.c | 1 + py313/_cursesmodule.c | 2 -- py313/clinic/_curses_panel.c.h | 24 ++++++++++++++++++++- py313/clinic/_cursesmodule.c.h | 39 +++++++++++++++++++++++++++++++++- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/py313/_curses_panel.c b/py313/_curses_panel.c index 2a8ece3..c8acd93 100644 --- a/py313/_curses_panel.c +++ b/py313/_curses_panel.c @@ -10,6 +10,7 @@ static const char PyCursesVersion[] = "2.1"; /* Includes */ + #include "Python.h" #include "py_curses.h" diff --git a/py313/_cursesmodule.c b/py313/_cursesmodule.c index fdd7082..fa922eb 100644 --- a/py313/_cursesmodule.c +++ b/py313/_cursesmodule.c @@ -100,8 +100,6 @@ static const char PyCursesVersion[] = "2.2"; /* Includes */ -#define PY_SSIZE_T_CLEAN - #include "Python.h" /* This function declaration was moved from pycore_structseq.h file to adapt diff --git a/py313/clinic/_curses_panel.c.h b/py313/clinic/_curses_panel.c.h index f64a707..7abe173 100644 --- a/py313/clinic/_curses_panel.c.h +++ b/py313/clinic/_curses_panel.c.h @@ -3,10 +3,32 @@ preserve [clinic start generated code]*/ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_modsupport.h" # include "pycore_runtime.h" // _Py_SINGLETON() #endif +// Export for 'math' shared extension +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( + PyObject *const *args, + Py_ssize_t nargs, + PyObject *kwargs, + PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, + int maxpos, + int minkw, + PyObject **buf); +#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ + (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ + (minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \ + _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ + (minpos), (maxpos), (minkw), (buf))) + +// Export for '_heapq' shared extension +PyAPI_FUNC(void) _PyArg_BadArgument( + const char *fname, + const char *displayname, + const char *expected, + PyObject *arg); PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, "bottom($self, /)\n" diff --git a/py313/clinic/_cursesmodule.c.h b/py313/clinic/_cursesmodule.c.h index 66ec1b0..ef7d250 100644 --- a/py313/clinic/_cursesmodule.c.h +++ b/py313/clinic/_cursesmodule.c.h @@ -3,11 +3,48 @@ preserve [clinic start generated code]*/ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_modsupport.h" # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif +PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, + Py_ssize_t, Py_ssize_t); +#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX) +#define _PyArg_CheckPositional(funcname, nargs, min, max) \ + ((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \ + || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) + +// Export for '_heapq' shared extension +PyAPI_FUNC(void) _PyArg_BadArgument( + const char *fname, + const char *displayname, + const char *expected, + PyObject *arg); + +// Export for '_curses' shared extension +PyAPI_FUNC(int) _PyArg_ParseStack( + PyObject *const *args, + Py_ssize_t nargs, + const char *format, + ...); + +// Export for 'math' shared extension +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( + PyObject *const *args, + Py_ssize_t nargs, + PyObject *kwargs, + PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, + int maxpos, + int minkw, + PyObject **buf); +#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ + (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ + (minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \ + _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ + (minpos), (maxpos), (minkw), (buf))) + PyDoc_STRVAR(_curses_window_addch__doc__, "addch([y, x,] ch, [attr=_curses.A_NORMAL])\n"