mirror of
https://github.com/python/cpython.git
synced 2024-12-18 22:34:08 +08:00
bpo-47208: Allow vendors to override CTYPES_MAX_ARGCOUNT (GH-32297)
This commit is contained in:
parent
1ecfe3d5ae
commit
d1b1c885d8
@ -4,6 +4,7 @@ from test import support
|
||||
|
||||
from ctypes import *
|
||||
from ctypes.test import need_symbol
|
||||
from _ctypes import CTYPES_MAX_ARGCOUNT
|
||||
import _ctypes_test
|
||||
|
||||
class Callbacks(unittest.TestCase):
|
||||
@ -293,8 +294,6 @@ class SampleCallbacksTestCase(unittest.TestCase):
|
||||
def func(*args):
|
||||
return len(args)
|
||||
|
||||
CTYPES_MAX_ARGCOUNT = 1024
|
||||
|
||||
# valid call with nargs <= CTYPES_MAX_ARGCOUNT
|
||||
proto = CFUNCTYPE(c_int, *(c_int,) * CTYPES_MAX_ARGCOUNT)
|
||||
cb = proto(func)
|
||||
|
@ -0,0 +1 @@
|
||||
Allow vendors to override :const:`CTYPES_MAX_ARGCOUNT`.
|
@ -5781,6 +5781,7 @@ _ctypes_add_objects(PyObject *mod)
|
||||
#endif
|
||||
MOD_ADD("RTLD_LOCAL", PyLong_FromLong(RTLD_LOCAL));
|
||||
MOD_ADD("RTLD_GLOBAL", PyLong_FromLong(RTLD_GLOBAL));
|
||||
MOD_ADD("CTYPES_MAX_ARGCOUNT", PyLong_FromLong(CTYPES_MAX_ARGCOUNT));
|
||||
MOD_ADD("ArgumentError", Py_NewRef(PyExc_ArgError));
|
||||
return 0;
|
||||
#undef MOD_ADD
|
||||
|
@ -18,7 +18,9 @@
|
||||
* This limit is enforced for the `alloca()` call in `_ctypes_callproc`,
|
||||
* to avoid allocating a massive buffer on the stack.
|
||||
*/
|
||||
#define CTYPES_MAX_ARGCOUNT 1024
|
||||
#ifndef CTYPES_MAX_ARGCOUNT
|
||||
#define CTYPES_MAX_ARGCOUNT 1024
|
||||
#endif
|
||||
|
||||
typedef struct tagPyCArgObject PyCArgObject;
|
||||
typedef struct tagCDataObject CDataObject;
|
||||
|
Loading…
Reference in New Issue
Block a user