Skip to content
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

describe PyEval_CallObjectWithKeywords and its replacement #86347

Open
jwuttke mannequin opened this issue Oct 28, 2020 · 4 comments
Open

describe PyEval_CallObjectWithKeywords and its replacement #86347

jwuttke mannequin opened this issue Oct 28, 2020 · 4 comments
Labels
3.9 only security fixes topic-C-API

Comments

@jwuttke
Copy link
Mannequin

jwuttke mannequin commented Oct 28, 2020

BPO 42181
Nosy @jdemeyer, @jwuttke

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-10-28.14:18:31.385>
labels = ['expert-C-API', '3.9']
title = 'describe PyEval_CallObjectWithKeywords and its replacement'
updated_at = <Date 2020-10-28.14:18:31.385>
user = 'https://github.com/jwuttke'

bugs.python.org fields:

activity = <Date 2020-10-28.14:18:31.385>
actor = 'jwuttke'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['C API']
creation = <Date 2020-10-28.14:18:31.385>
creator = 'jwuttke'
dependencies = []
files = []
hgrepos = []
issue_num = 42181
keywords = []
message_count = 1.0
messages = ['379828']
nosy_count = 2.0
nosy_names = ['jdemeyer', 'jwuttke']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue42181'
versions = ['Python 3.9']

@jwuttke
Copy link
Mannequin Author

jwuttke mannequin commented Oct 28, 2020

The current 3.9 docs do not describe PyEval_CallObjectWithKeywords, among other PyEval_CallObject* functions.

Yes, I know, these functions are deprecated. But they are still part of the API; they ought to be documented.

Rather, given that they are deprecated, there is more need than ever to document them: The documentation should specify when they have been deprecated, until then they are guaranteed to be supported, and most importantly, how they are to be replaced.

Fulltext search leads me to the 3.9 Changelog that says: »PyEval_CallFunction, PyEval_CallMethod and PyEval_CallObjectWithKeywords are deprecated. Use PyObject_Call() and its variants instead.« This is far not enough. As a maintainer of 3rd-party code with no knowledge of and no interest in the Python C API, I do not want to spend half a day on finding out which variant to use, and how argument lists differ.

@jwuttke jwuttke mannequin added 3.9 only security fixes topic-C-API labels Oct 28, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@Mekk
Copy link

Mekk commented Aug 30, 2022

+1. Just searching how should I replace that…

@Mekk
Copy link

Mekk commented Aug 30, 2022

In the end I had to replace

PyObject* ret = PyEval_CallObjectWithKeywords(func, arg, kw);

with

if (arg != NULL && ! PyTuple_Check(arg)) {
    PyErr_SetString(PyExc_TypeError,
                    "argument list must be a tuple");
    return NULL;
}
if (kw != NULL && !PyDict_Check(kw)) {
    PyErr_SetString(PyExc_TypeError,
                    "keyword list must be a dictionary");
    return NULL;
}
PyObject* ret = (arg == NULL)
    ? _PyObject_FastCallDict(func, NULL, 0, kw)
    : PyObject_Call(func, arg, kw);

so I think that the decision to deprecate the former was made without appropriate consideration (replacement is much longer and I had to use private function).

@sparkprime
Copy link

I'm seeing this deprecation warning now and I'm not sure what to do about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes topic-C-API
Projects
None yet
Development

No branches or pull requests

2 participants