Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaeac14b

Browse files
remove FUNCFLAG_VARIADIC
1 parent80f852b commitaeac14b

File tree

6 files changed

+6
-47
lines changed

6 files changed

+6
-47
lines changed

‎Doc/library/ctypes.rst‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,13 +1579,6 @@ They are instances of a private class:
15791579
value usable as argument (integer, string, ctypes instance). This allows
15801580
defining adapters that can adapt custom objects as function parameters.
15811581

1582-
..attribute::variadic
1583-
1584-
Assign a boolean to specify that the function takes a variable number of
1585-
arguments. This does not matter on most platforms, but for Apple arm64
1586-
platforms variadic functions have a different calling convention than
1587-
normal functions.
1588-
15891582
..attribute::errcheck
15901583

15911584
Assign a Python function or another callable to this attribute. The

‎Lib/test/test_bytes.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,6 @@ def test_from_format(self):
10341034
c_char_p)
10351035

10361036
PyBytes_FromFormat=pythonapi.PyBytes_FromFormat
1037-
PyBytes_FromFormat.variadic=True
10381037
PyBytes_FromFormat.argtypes= (c_char_p,)
10391038
PyBytes_FromFormat.restype=py_object
10401039

‎Lib/test/test_unicode.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,6 @@ def test_from_format(self):
25162516
name="PyUnicode_FromFormat"
25172517
_PyUnicode_FromFormat=getattr(pythonapi,name)
25182518
_PyUnicode_FromFormat.argtypes= (c_char_p,)
2519-
_PyUnicode_FromFormat.variadic=True
25202519
_PyUnicode_FromFormat.restype=py_object
25212520

25222521
defPyUnicode_FromFormat(format,*args):

‎Modules/_ctypes/_ctypes.c‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,35 +3320,6 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject *self, void *Py_UNUSED(ignored))
33203320
}
33213321
}
33223322

3323-
staticint
3324-
PyCFuncPtr_set_variadic(PyCFuncPtrObject*self,PyObject*ob,void*Py_UNUSED(ignored))
3325-
{
3326-
StgDictObject*dict=PyObject_stgdict((PyObject*)self);
3327-
assert(dict);
3328-
intr=PyObject_IsTrue(ob);
3329-
if (r==1) {
3330-
dict->flags |=FUNCFLAG_VARIADIC;
3331-
return0;
3332-
}elseif (r==0) {
3333-
dict->flags &= ~FUNCFLAG_VARIADIC;
3334-
return0;
3335-
}else {
3336-
return-1;
3337-
}
3338-
}
3339-
3340-
staticPyObject*
3341-
PyCFuncPtr_get_variadic(PyCFuncPtrObject*self,void*Py_UNUSED(ignored))
3342-
{
3343-
StgDictObject*dict=PyObject_stgdict((PyObject*)self);
3344-
assert(dict);/* Cannot be NULL for PyCFuncPtrObject instances */
3345-
if (dict->flags&FUNCFLAG_VARIADIC)
3346-
Py_RETURN_TRUE;
3347-
else
3348-
Py_RETURN_FALSE;
3349-
}
3350-
3351-
33523323
staticint
33533324
PyCFuncPtr_set_argtypes(PyCFuncPtrObject*self,PyObject*ob,void*Py_UNUSED(ignored))
33543325
{
@@ -3394,8 +3365,6 @@ static PyGetSetDef PyCFuncPtr_getsets[] = {
33943365
{"argtypes", (getter)PyCFuncPtr_get_argtypes,
33953366
(setter)PyCFuncPtr_set_argtypes,
33963367
"specify the argument types",NULL },
3397-
{"variadic", (getter)PyCFuncPtr_get_variadic, (setter)PyCFuncPtr_set_variadic,
3398-
"specify if function takes variable number of arguments",NULL },
33993368
{NULL,NULL }
34003369
};
34013370

@@ -5870,7 +5839,6 @@ PyInit__ctypes(void)
58705839
PyModule_AddObject(m,"FUNCFLAG_USE_ERRNO",PyLong_FromLong(FUNCFLAG_USE_ERRNO));
58715840
PyModule_AddObject(m,"FUNCFLAG_USE_LASTERROR",PyLong_FromLong(FUNCFLAG_USE_LASTERROR));
58725841
PyModule_AddObject(m,"FUNCFLAG_PYTHONAPI",PyLong_FromLong(FUNCFLAG_PYTHONAPI));
5873-
PyModule_AddObject(m,"FUNCFLAG_VARIADIC",PyLong_FromLong(FUNCFLAG_VARIADIC));
58745842
PyModule_AddStringConstant(m,"__version__","1.1.0");
58755843

58765844
PyModule_AddObject(m,"_memmove_addr",PyLong_FromVoidPtr(memmove));

‎Modules/_ctypes/callproc.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,12 @@ static int _call_function_pointer(int flags,
847847
# defineHAVE_FFI_PREP_CIF_VAR_RUNTIME false
848848
# endif
849849

850-
/* Everyone SHOULD set f.variadic=True on variadic function pointers, but
851-
* lots of existing code will not. If there's at least one arg and more
852-
* args are passed than are defined in the prototype, then it must be a
853-
* variadic function. */
854-
boolis_variadic= (flags&FUNCFLAG_VARIADIC)|| (argtypecount!=0&&argcount>argtypecount);
850+
/* Even on Apple-arm64 the calling convention for variadic functions conincides
851+
* with the standard calling convention in the case that the function called
852+
* only with its fixed arguments. Thus, we do not need a special flag to be
853+
* set on variadic functions. We treat a function as variadic if it is called
854+
* with a nonzero number of variadic arguments */
855+
boolis_variadic= (argtypecount!=0&&argcount>argtypecount);
855856
(void)is_variadic;
856857

857858
#if defined(__APPLE__)&& defined(__arm64__)

‎Modules/_ctypes/ctypes.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ PyObject *_ctypes_callproc(PPROC pProc,
285285
#defineFUNCFLAG_PYTHONAPI 0x4
286286
#defineFUNCFLAG_USE_ERRNO 0x8
287287
#defineFUNCFLAG_USE_LASTERROR 0x10
288-
#defineFUNCFLAG_VARIADIC 0x20
289288

290289
#defineTYPEFLAG_ISPOINTER 0x100
291290
#defineTYPEFLAG_HASPOINTER 0x200

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp