Skip to content

Commit 1c21781

Browse files
pmbarrett314stephanosio
authored andcommitted
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 c0d5376 commit 1c21781

File tree

4 files changed

+63
-10
lines changed

4 files changed

+63
-10
lines changed

Diff for: py313/_curses_panel.c

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

1111
/* Includes */
1212

13-
// clinic/_curses_panel.c.h uses internal pycore_modsupport.h API
14-
#ifndef Py_BUILD_CORE_BUILTIN
15-
# define Py_BUILD_CORE_MODULE 1
16-
#endif
1713

1814
#include "Python.h"
1915

Diff for: py313/_cursesmodule.c

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

101101
/* Includes */
102102

103-
#ifndef Py_BUILD_CORE_BUILTIN
104-
# define Py_BUILD_CORE_MODULE 1
105-
#endif
106-
107103
#include "Python.h"
108104

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

Diff for: py313/clinic/_curses_panel.c.h

+24-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,30 @@ preserve
55
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
66
# include "pycore_runtime.h" // _Py_SINGLETON()
77
#endif
8-
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
8+
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);
932

1033
PyDoc_STRVAR(_curses_panel_panel_bottom__doc__,
1134
"bottom($self, /)\n"

Diff for: py313/clinic/_cursesmodule.c.h

+39-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,45 @@ preserve
66
# include "pycore_gc.h" // PyGC_Head
77
# include "pycore_runtime.h" // _Py_ID()
88
#endif
9-
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
9+
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+
1048

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

0 commit comments

Comments
 (0)