New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C API] Removed private _PyArg_Parser API has no replacement in Python 3.13 #112136
Comments
|
A code search on
|
|
These APIs are effectively required for using Notably "Private, but documented, and partially considered part of the stable ABI" is not the same thing as "Private". Removing these functions leaves no API to interact with these documented call mechanisms. Unless you intend to remove Anecdotally, we make extensive use of |
|
What I'm trying to do here is to list projects using these projects, see how they use the API, and which public API is needed.
Do you have some examples? Which calling convention do you use?
This situation is unfortunate. METH_FASTCALL was created as a private API but apparently, it was adopted outside Python before it was standardized by PEP 590 – Vectorcall: a fast calling protocol for CPython. As the author of
In terms of functions, so far the following functions were mentioned:
Is the number of arguments always a signed |
I don't think we do anything fancy, basically the same straightforward code you would see pop out of argument clinic: // Tiny METH_FASTCALL example function
static PyObject *print_func(PyObject *self,
PyObject *const *args, Py_ssize_t nargs) {
const char *str;
if(!_PyArg_ParseStack(args, nargs, "s", &str))
return NULL;
puts(str);
Py_RETURN_NONE;
}or // Tiny METH_FASTCALL | METH_KEYWORDS example function
static PyObject* prefix_print(PyObject* self, PyObject* const* args,
Py_ssize_t nargs, PyObject* kwnames) {
static const char* _keywords[] = {"", "prefix", NULL};
static _PyArg_Parser _parser = {.keywords = _keywords,
.format = "s|s:prefix_print"};
const char* str;
const char* prefix = NULL;
if(!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &str,
&prefix))
return NULL;
if(prefix)
printf("%s", prefix);
puts(str);
Py_RETURN_NONE;
}for A quick Ctrl-F shows no one using
Ya 100%. I understand I'm just some random and you're the core dev here, just wanted to raise the objection that breaking this functionality without having that replacement ready doesn't seem like a win to me. The APIs are already internal, there's no stability contract, but if they exist anyway in an unbroken state, what's the harm in leaving them accessible until a replacement is available? As a practical matter if these disappeared we would be replicating the declarations in our own headers for the Python versions where no solutions existed, and that seems like a pointless maintenance burden to push out into the world.
|
Copy of @tacaswell's message:
The _PyArg_Parser API is used by Argument Clinic to generate efficient code parsing function arguments.
Since Python 3.12, when targeting Python internals, Argument Clinic initializes
_PyArg_Parser.kwtuplewith singletons objects using the_Py_SINGLETON(name)API. This API cannot be used outside Python.Private functions with a
_PyArg_Parserargument:cc @serhiy-storchaka
The text was updated successfully, but these errors were encountered: