mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-39245: Switch to public API for Vectorcall (GH-18460)
The bulk of this patch was generated automatically with:
    for name in \
        PyObject_Vectorcall \
        Py_TPFLAGS_HAVE_VECTORCALL \
        PyObject_VectorcallMethod \
        PyVectorcall_Function \
        PyObject_CallOneArg \
        PyObject_CallMethodNoArgs \
        PyObject_CallMethodOneArg \
    ;
    do
        echo $name
        git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g"
    done
    old=_PyObject_FastCallDict
    new=PyObject_VectorcallDict
    git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g"
and then cleaned up:
- Revert changes to in docs & news
- Revert changes to backcompat defines in headers
- Nudge misaligned comments
			
			
This commit is contained in:
		
							parent
							
								
									f3e7ea5b8c
								
							
						
					
					
						commit
						ffd9753a94
					
				
					 56 changed files with 194 additions and 194 deletions
				
			
		|  | @ -593,7 +593,7 @@ call_show_warning(PyObject *category, PyObject *text, PyObject *message, | |||
|     if (msg == NULL) | ||||
|         goto error; | ||||
| 
 | ||||
|     res = _PyObject_CallOneArg(show_fn, msg); | ||||
|     res = PyObject_CallOneArg(show_fn, msg); | ||||
|     Py_DECREF(show_fn); | ||||
|     Py_DECREF(msg); | ||||
| 
 | ||||
|  | @ -654,7 +654,7 @@ warn_explicit(PyObject *category, PyObject *message, | |||
|     } | ||||
|     else { | ||||
|         text = message; | ||||
|         message = _PyObject_CallOneArg(category, message); | ||||
|         message = PyObject_CallOneArg(category, message); | ||||
|         if (message == NULL) | ||||
|             goto cleanup; | ||||
|     } | ||||
|  | @ -997,7 +997,7 @@ get_source_line(PyObject *module_globals, int lineno) | |||
|         return NULL; | ||||
|     } | ||||
|     /* Call get_source() to get the source code. */ | ||||
|     source = _PyObject_CallOneArg(get_source, module_name); | ||||
|     source = PyObject_CallOneArg(get_source, module_name); | ||||
|     Py_DECREF(get_source); | ||||
|     Py_DECREF(module_name); | ||||
|     if (!source) { | ||||
|  | @ -1284,7 +1284,7 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro) | |||
|     int warned = 0; | ||||
|     PyObject *fn = get_warnings_attr(&PyId__warn_unawaited_coroutine, 1); | ||||
|     if (fn) { | ||||
|         PyObject *res = _PyObject_CallOneArg(fn, coro); | ||||
|         PyObject *res = PyObject_CallOneArg(fn, coro); | ||||
|         Py_DECREF(fn); | ||||
|         if (res || PyErr_ExceptionMatches(PyExc_RuntimeWarning)) { | ||||
|             warned = 1; | ||||
|  |  | |||
|  | @ -56,7 +56,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs) | |||
|             } | ||||
|             continue; | ||||
|         } | ||||
|         new_base = _PyObject_CallOneArg(meth, bases); | ||||
|         new_base = PyObject_CallOneArg(meth, bases); | ||||
|         Py_DECREF(meth); | ||||
|         if (!new_base) { | ||||
|             goto error; | ||||
|  | @ -203,7 +203,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, | |||
|     } | ||||
|     else { | ||||
|         PyObject *pargs[2] = {name, bases}; | ||||
|         ns = _PyObject_FastCallDict(prep, pargs, 2, mkw); | ||||
|         ns = PyObject_VectorcallDict(prep, pargs, 2, mkw); | ||||
|         Py_DECREF(prep); | ||||
|     } | ||||
|     if (ns == NULL) { | ||||
|  | @ -229,7 +229,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, | |||
|             } | ||||
|         } | ||||
|         PyObject *margs[3] = {name, bases, ns}; | ||||
|         cls = _PyObject_FastCallDict(meta, margs, 3, mkw); | ||||
|         cls = PyObject_VectorcallDict(meta, margs, 3, mkw); | ||||
|         if (cls != NULL && PyType_Check(cls) && PyCell_Check(cell)) { | ||||
|             PyObject *cell_cls = PyCell_GET(cell); | ||||
|             if (cell_cls != cls) { | ||||
|  | @ -489,7 +489,7 @@ builtin_breakpoint(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb | |||
|     } | ||||
| 
 | ||||
|     Py_INCREF(hook); | ||||
|     PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); | ||||
|     PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); | ||||
|     Py_DECREF(hook); | ||||
|     return retval; | ||||
| } | ||||
|  | @ -575,7 +575,7 @@ filter_next(filterobject *lz) | |||
|             ok = PyObject_IsTrue(item); | ||||
|         } else { | ||||
|             PyObject *good; | ||||
|             good = _PyObject_CallOneArg(lz->func, item); | ||||
|             good = PyObject_CallOneArg(lz->func, item); | ||||
|             if (good == NULL) { | ||||
|                 Py_DECREF(item); | ||||
|                 return NULL; | ||||
|  | @ -1631,7 +1631,7 @@ min_max(PyObject *args, PyObject *kwds, int op) | |||
|     while (( item = PyIter_Next(it) )) { | ||||
|         /* get the value from the key function */ | ||||
|         if (keyfunc != NULL) { | ||||
|             val = _PyObject_CallOneArg(keyfunc, item); | ||||
|             val = PyObject_CallOneArg(keyfunc, item); | ||||
|             if (val == NULL) | ||||
|                 goto Fail_it_item; | ||||
|         } | ||||
|  | @ -2178,7 +2178,7 @@ builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits) | |||
|     if (ndigits == Py_None) | ||||
|         result = _PyObject_CallNoArg(round); | ||||
|     else | ||||
|         result = _PyObject_CallOneArg(round, ndigits); | ||||
|         result = PyObject_CallOneArg(round, ndigits); | ||||
|     Py_DECREF(round); | ||||
|     return result; | ||||
| } | ||||
|  | @ -2234,7 +2234,7 @@ builtin_sorted(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject | |||
|     } | ||||
| 
 | ||||
|     assert(nargs >= 1); | ||||
|     v = _PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); | ||||
|     v = PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); | ||||
|     Py_DECREF(callable); | ||||
|     if (v == NULL) { | ||||
|         Py_DECREF(newlist); | ||||
|  |  | |||
|  | @ -1874,7 +1874,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
|                 Py_DECREF(value); | ||||
|                 goto error; | ||||
|             } | ||||
|             res = _PyObject_CallOneArg(hook, value); | ||||
|             res = PyObject_CallOneArg(hook, value); | ||||
|             Py_DECREF(value); | ||||
|             if (res == NULL) | ||||
|                 goto error; | ||||
|  | @ -3271,7 +3271,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
|             assert(!PyLong_Check(exc)); | ||||
|             exit_func = PEEK(7); | ||||
|             PyObject *stack[4] = {NULL, exc, val, tb}; | ||||
|             res = _PyObject_Vectorcall(exit_func, stack + 1, | ||||
|             res = PyObject_Vectorcall(exit_func, stack + 1, | ||||
|                     3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); | ||||
|             if (res == NULL) | ||||
|                 goto error; | ||||
|  | @ -4846,7 +4846,7 @@ trace_call_function(PyThreadState *tstate, | |||
| { | ||||
|     PyObject *x; | ||||
|     if (PyCFunction_Check(func)) { | ||||
|         C_TRACE(x, _PyObject_Vectorcall(func, args, nargs, kwnames)); | ||||
|         C_TRACE(x, PyObject_Vectorcall(func, args, nargs, kwnames)); | ||||
|         return x; | ||||
|     } | ||||
|     else if (Py_TYPE(func) == &PyMethodDescr_Type && nargs > 0) { | ||||
|  | @ -4862,13 +4862,13 @@ trace_call_function(PyThreadState *tstate, | |||
|         if (func == NULL) { | ||||
|             return NULL; | ||||
|         } | ||||
|         C_TRACE(x, _PyObject_Vectorcall(func, | ||||
|         C_TRACE(x, PyObject_Vectorcall(func, | ||||
|                                         args+1, nargs-1, | ||||
|                                         kwnames)); | ||||
|         Py_DECREF(func); | ||||
|         return x; | ||||
|     } | ||||
|     return _PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); | ||||
|     return PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); | ||||
| } | ||||
| 
 | ||||
| /* Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault()
 | ||||
|  | @ -4887,7 +4887,7 @@ call_function(PyThreadState *tstate, PyObject ***pp_stack, Py_ssize_t oparg, PyO | |||
|         x = trace_call_function(tstate, func, stack, nargs, kwnames); | ||||
|     } | ||||
|     else { | ||||
|         x = _PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); | ||||
|         x = PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); | ||||
|     } | ||||
| 
 | ||||
|     assert((x != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); | ||||
|  |  | |||
|  | @ -147,7 +147,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) | |||
|         func = PyList_GetItem(interp->codec_search_path, i); | ||||
|         if (func == NULL) | ||||
|             goto onError; | ||||
|         result = _PyObject_CallOneArg(func, v); | ||||
|         result = PyObject_CallOneArg(func, v); | ||||
|         if (result == NULL) | ||||
|             goto onError; | ||||
|         if (result == Py_None) { | ||||
|  | @ -317,7 +317,7 @@ PyObject *codec_getstreamcodec(const char *encoding, | |||
|     if (errors != NULL) | ||||
|         streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors); | ||||
|     else | ||||
|         streamcodec = _PyObject_CallOneArg(codeccls, stream); | ||||
|         streamcodec = PyObject_CallOneArg(codeccls, stream); | ||||
|     Py_DECREF(codecs); | ||||
|     return streamcodec; | ||||
| } | ||||
|  |  | |||
|  | @ -93,7 +93,7 @@ _PyErr_CreateException(PyObject *exception, PyObject *value) | |||
|         return PyObject_Call(exception, value, NULL); | ||||
|     } | ||||
|     else { | ||||
|         return _PyObject_CallOneArg(exception, value); | ||||
|         return PyObject_CallOneArg(exception, value); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -907,7 +907,7 @@ PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, | |||
|         goto done; | ||||
|     } | ||||
| 
 | ||||
|     error = _PyObject_FastCallDict(exception, &msg, 1, kwargs); | ||||
|     error = PyObject_VectorcallDict(exception, &msg, 1, kwargs); | ||||
|     if (error != NULL) { | ||||
|         _PyErr_SetObject(tstate, (PyObject *)Py_TYPE(error), error); | ||||
|         Py_DECREF(error); | ||||
|  | @ -1422,7 +1422,7 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, PyObject *obj) | |||
|         goto default_hook; | ||||
|     } | ||||
| 
 | ||||
|     PyObject *res = _PyObject_CallOneArg(hook, hook_args); | ||||
|     PyObject *res = PyObject_CallOneArg(hook, hook_args); | ||||
|     Py_DECREF(hook_args); | ||||
|     if (res != NULL) { | ||||
|         Py_DECREF(res); | ||||
|  |  | |||
|  | @ -1206,7 +1206,7 @@ get_path_importer(PyThreadState *tstate, PyObject *path_importer_cache, | |||
|         PyObject *hook = PyList_GetItem(path_hooks, j); | ||||
|         if (hook == NULL) | ||||
|             return NULL; | ||||
|         importer = _PyObject_CallOneArg(hook, p); | ||||
|         importer = PyObject_CallOneArg(hook, p); | ||||
|         if (importer != NULL) | ||||
|             break; | ||||
| 
 | ||||
|  |  | |||
|  | @ -519,7 +519,7 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb | |||
|         return NULL; | ||||
|     } | ||||
|     PyMem_RawFree(envar); | ||||
|     PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); | ||||
|     PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); | ||||
|     Py_DECREF(hook); | ||||
|     return retval; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Petr Viktorin
						Petr Viktorin