Skip to content

Commit 9fc8f6b

Browse files
committed
Add declarations for private functions from pycore_modsupport
python/cpython#110964 Copied from pycore_modsupport.h remove PY_SSIZE_T_CLEAN definition python/cpython#104922
1 parent 9037c0c commit 9fc8f6b

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

py313/_curses_panel.c

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static const char PyCursesVersion[] = "2.1";
1010

1111
/* Includes */
1212

13+
1314
#include "Python.h"
1415

1516
#include "py_curses.h"

py313/_cursesmodule.c

-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ static const char PyCursesVersion[] = "2.2";
100100

101101
/* Includes */
102102

103-
#define PY_SSIZE_T_CLEAN
104-
105103
#include "Python.h"
106104

107105
/* This function declaration was moved from pycore_structseq.h file to adapt

py313/clinic/_curses_panel.c.h

+23-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,32 @@ preserve
33
[clinic start generated code]*/
44

55
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6-
# include "pycore_modsupport.h"
76
# include "pycore_runtime.h" // _Py_SINGLETON()
87
#endif
98

9+
// Export for 'math' shared extension
10+
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
11+
PyObject *const *args,
12+
Py_ssize_t nargs,
13+
PyObject *kwargs,
14+
PyObject *kwnames,
15+
struct _PyArg_Parser *parser,
16+
int minpos,
17+
int maxpos,
18+
int minkw,
19+
PyObject **buf);
20+
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
21+
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
22+
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
23+
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
24+
(minpos), (maxpos), (minkw), (buf)))
25+
26+
// Export for '_heapq' shared extension
27+
PyAPI_FUNC(void) _PyArg_BadArgument(
28+
const char *fname,
29+
const char *displayname,
30+
const char *expected,
31+
PyObject *arg);
1032

1133
PyDoc_STRVAR(_curses_panel_panel_bottom__doc__,
1234
"bottom($self, /)\n"

py313/clinic/_cursesmodule.c.h

+38-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,48 @@ preserve
33
[clinic start generated code]*/
44

55
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6-
# include "pycore_modsupport.h"
76
# include "pycore_gc.h" // PyGC_Head
87
# include "pycore_runtime.h" // _Py_ID()
98
#endif
109

10+
PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
11+
Py_ssize_t, Py_ssize_t);
12+
#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX)
13+
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
14+
((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
15+
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
16+
17+
// Export for '_heapq' shared extension
18+
PyAPI_FUNC(void) _PyArg_BadArgument(
19+
const char *fname,
20+
const char *displayname,
21+
const char *expected,
22+
PyObject *arg);
23+
24+
// Export for '_curses' shared extension
25+
PyAPI_FUNC(int) _PyArg_ParseStack(
26+
PyObject *const *args,
27+
Py_ssize_t nargs,
28+
const char *format,
29+
...);
30+
31+
// Export for 'math' shared extension
32+
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
33+
PyObject *const *args,
34+
Py_ssize_t nargs,
35+
PyObject *kwargs,
36+
PyObject *kwnames,
37+
struct _PyArg_Parser *parser,
38+
int minpos,
39+
int maxpos,
40+
int minkw,
41+
PyObject **buf);
42+
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
43+
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
44+
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
45+
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
46+
(minpos), (maxpos), (minkw), (buf)))
47+
1148

1249
PyDoc_STRVAR(_curses_window_addch__doc__,
1350
"addch([y, x,] ch, [attr=_curses.A_NORMAL])\n"

0 commit comments

Comments
 (0)