-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-35059: Convert PyObject_INIT() to function #10077
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
Conversation
Strange, AppVeyor seems stuck: " continuous-integration/appveyor/pr Expected — Waiting for status to be reported ". I will close/reopen the issue to schedule a new job. |
My PR #10079 adds a new Py_STATIC_INLINE() macro. I will wait until the other PR is merged to be able to use Py_STATIC_INLINE() in this PR. |
* Convert PyObject_INIT() and PyObject_INIT_VAR() macros to static inline functions. * Fix usage of these functions: cast to PyObject* or PyVarObject*.
Doesn't this break many third party modules which use |
I don't know how to test that. Which kind of failure do you expect? According to the CPython code base, the main annoyance is the introduction of a cast warning because the macros now require a strict type: PyObject* and PyVarObject*. If you consider that we must no force all C extensions author to fix their code, I can add a macro which does the cast for them. |
First I wanted to remove the return value, since I don't see the point. But inside CPython, a lot of code rely on the return value. So I decided to keep it to reduce the annoyance... and avoid breaking code. |
You have added some One option to avoid it is using |
Right. Do you consider that it's an issue? It's just a compiler warning. IMHO it's a good thing that developers cast explicitly, no? A function (macro currently) which accepts any type is just weird. If you prefer, I can rename the macro to _PyObject_INIT() and add:
So the "function" accepts any type, as your void* suggestion. @methane: what do you think? |
I expected it cause compile error, not warning. |
It only causes the compilation to fail if you use -Werror. Very few people use this option, and if they use it, they are well aware of the effect of the flag :-) |
If too many users complain, we can add the macro doing the cast later. Even after the 3.8.0 release. |
inline functions.
https://bugs.python.org/issue35059