Issue 33012: Invalid function cast warnings with gcc 8 for METH_NOARGS (original) (raw)
Created on 2018-03-06 11:18 by siddhesh, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (49)
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-03-06 11:18
gcc 8 has added a new warning heuristic to detect invalid function casts and a stock python build seems to hit that warning quite often. The most common is the cast of a METH_NOARGS function (that uses just one argument) to a PyCFunction. The fix is pretty simple but needs to be applied widely. I'm slowly knocking them off in my spare time; WIP here, which has a few other types of warnings mixed in that I'll sift out during submission and also create separate bug reports for:
https://github.com/siddhesh/cpython/tree/func-cast
I'll clean up and post PR(s) once I am done but I figured I should file this report first since it is a pretty big change in terms of number of files touched and wanted to be sure that I'm making changes the way the community prefers.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-03-06 11:32
Argument Clinic generates the following declaration for the second parameter of METH_NOARGS functions:
PyObject *Py_UNUSED(ignored)
It would be nice to follow the same style.
If the first parameter is of type PyObject* too, the explicit cast to PyCFunction can be removed.
Skip the curses module. It will be converted to Argument Clinic.
Author: Charalampos Stratakis (cstratak) *
Date: 2018-03-06 11:38
We are getting hit by that quite often on Fedora, with the transition to gcc 8 and it creates unnecessary noise at our build logs. Thanks for working on that.
When you sent your PR I can test it within our build system and verify if it works.
Author: Antti Haapala (ztane) *
Date: 2018-03-15 11:33
I don't have GCC 8 so I cannot verify this bug, but function pointer casts are fine - any function pointer can be cast to any other function pointer - it is only that they must not be called unless cast back again to be compatible with the function definition. Any fix to the contrary might well cause undefined behaviour!
Could you provide a sample of the actual warnings so that they could be studied?
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-03-15 12:07
I don't have GCC 8 so I cannot verify this bug, but function pointer casts are fine - any function pointer can be cast to any other function pointer - it is only that they must not be called unless cast back again to be compatible with the function definition. Any fix to the contrary might well cause undefined behaviour!
Please see the attached PR; METH_NOARGS callbacks are inconsistent in their signature and many have just one argument while they're called with two arguments, the second being NULL. The patch fixes these to consistently take and call with two arguments.
Could you provide a sample of the actual warnings so that they could be studied?
Here's one of a few hundred.
Objects/bytesobject.c:3085:25: warning: cast between incompatible function types from ‘PyObject * (*)(striterobject )’ {aka ‘struct _object * ()(struct )’} to ‘PyObject * ()(PyObject *, PyObject )’ {aka ‘struct _object * ()(struct _object *, struct _object *)’} [-Wcast-function-type] {"reduce", (PyCFunction)striter_reduce, METH_NOARGS, ^ This is a new warning in gcc8, so you'll likely not find much reference, but here's a gcc bug report that might give you more context:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84531
Author: Antti Haapala (ztane) *
Date: 2018-03-15 15:27
Yea, I looked into ceval.c
and the function is called incorrectly, so there is undefined behaviour there - it has been wrong all along, in 3.5 all the way down to 2-something
if (flags & (METH_NOARGS | METH_O)) {
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
if (flags & METH_NOARGS && na == 0) {
C_TRACE(x, (*meth)(self,NULL));
x = _Py_CheckFunctionResult(func, x, NULL);
}
The warning in GCC shouldn't probably have been enabled at all in -Wall -Wextra
because the cast is explicit. However, it is somewhat true.
However, the correct way to fix would be to have the METH_NOARGS case cast the function to the right prototype. There exists lots of existing code that is going to break too.
Perhaps PyCFunction should declare no prototype, i.e. empty parentheses, for backwards compatibility:
typedef PyObject *(*PyCFunction)();
and deprecate it; start using a new typedef for it - and then add proper casts in every place that call a function.
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-03-15 15:54
The warning in GCC shouldn't probably have been enabled at all in
-Wall -Wextra
because the cast is explicit. However, it is somewhat true.
The explicit cast is precisely what enables the more nuanced function cast warning where it checks the function for type compatibility. That is, it will check the types of the return and arguments and then warn in case of mismatch.
However, the correct way to fix would be to have the METH_NOARGS case cast the function to the right prototype. There exists lots of existing code that is going to break too.
AFAICT, there is no right prototype for the METH_NOARGS function; there used to be a PyCFunctionWithNoArguments but that seems to have fallen out of favour some time back. The prototype that seems to be commonly in use (and in clinic as well, which is what I based my patches on) is the PyCFunction, which seems like a safe way to do things.
Perhaps PyCFunction should declare no prototype, i.e. empty parentheses, for backwards compatibility:
typedef PyObject *(*PyCFunction)();
and deprecate it; start using a new typedef for it - and then add proper casts in every place that call a function.
I have a patch in the works that makes it PyObject ()(PyObject *, PyObject *, ...)
which allows for two compulsory arguments (fits in with most cases, provided the METH_NOARGS patch is accepted) and then the rest depending on the type of the cast function. The rest of the PyMethodDef functions are much simpler fixes this way. It also seems like a more intuitive description of the callbacks.
Then there are getter and setter and other function pointers that need similar fixes to METH_NOARGS.
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-03-15 15:55
I forgot to clarify that the function cast warning allows for variable argument casts as a wildcard, which is my basis for the PyObject ()(PyObject *, PyObject *, ...) fix proposal.
Author: Martin Panter (martin.panter) *
Date: 2018-04-02 03:52
Siddhesh, it looks like your fixes make the C function signatures match the signature expected in the PyMethodDef structure. If so, I suggest to remove the (PyCFunction) casts from those structure definitions as well. For instance, now that we have
PyObject *Noddy_name(Noddy *self, PyObject *Py_UNUSED(ignored))
I suggest changing
PyMethodDef Noddy_methods[] = { {"name", (PyCFunction)Noddy_name, METH_NOARGS, ...
to
PyMethodDef Noddy_methods[] = { {"name", Noddy_name, METH_NOARGS, ...
I suspect the casts were only added to hide compiler warnings related to this bug.
If you are proposing to add an ellipsis (...) to the definition of PyCFunction, that seems misguided. I understand this is incompatible under standard C. Are you relying on a GCC extension perhaps? Python is used with other compilers too.
Author: Martin Panter (martin.panter) *
Date: 2018-04-05 00:13
Sorry, I realize there is a problem remaining with the pointer types for "Noddy_name" (Noddy vs PyObject pointers), so you can't remove the cast there. But my suggestion should still apply to other places, for instance the "error_out" method in Doc/howto/cporting.rst.
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-04-09 10:41
Fair enough, I'll reduce my scope of changes for this patchset, especially since I'm unable to find enough time to work on the remaining changes I had thought of in the coming weeks.
I'll post an updated patch soonish.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-04-29 18:59
New changeset 55edd0c185ad2d895b5d73e47d67049bc156b654 by Serhiy Storchaka (Siddhesh Poyarekar) in branch 'master': bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (GH-6030) https://github.com/python/cpython/commit/55edd0c185ad2d895b5d73e47d67049bc156b654
Author: STINNER Victor (vstinner) *
Date: 2018-04-30 08:02
The commit 55edd0c185ad2d895b5d73e47d67049bc156b654 introduced a new warning:
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -Wstrict-prototypes -O0 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I. -I./Include -fPIC -DPy_BUILD_CORE -o Objects/longobject.o Objects/longobject.c Objects/longobject.c:5359:5: warning: initialisation depuis un type pointeur incompatible [-Wincompatible-pointer-types] long_long, /nb_int/ ^~~~~~~~~ Objects/longobject.c:5359:5: note: (près de l'initialisation de « long_as_number.nb_int ») Objects/longobject.c:5376:5: warning: initialisation depuis un type pointeur incompatible [-Wincompatible-pointer-types] long_long, /* nb_index */ ^~~~~~~~~ Objects/longobject.c:5376:5: note: (près de l'initialisation de « long_as_number.nb_index »)
It seems like a conversion to (unaryfunc) is needed when passing long_long as nb_int in long_as_number.
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-04-30 08:07
Yeah, there are multiple such uses that need wrappers to actually fix for gcc8, which will be released this week. I think I'll have more time for some more patches in this vein this weekend.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-04-30 12:35
New changeset 6405feecda6a5d5dd7a4240eb3054a2676ed29b1 by Serhiy Storchaka in branch 'master': bpo-33012: Fix invalid function casts for long_long. (GH-6652) https://github.com/python/cpython/commit/6405feecda6a5d5dd7a4240eb3054a2676ed29b1
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-05-10 10:28
The following PRs fix warnings in casts to PyCFunction for method conventions different from METH_NOARGS, METH_O and METH_VARARGS. PR 6748 does this for Argument Clinic generated code (all files except Tools/clinic/clinic.py are generated). PR 6749 does it for hand-written code. It also fixes few missed or new cases for METH_NOARGS.
Author: Charalampos Stratakis (cstratak) *
Date: 2018-05-10 10:31
Is it possible/feasible to fix that for the 3.7 and 3.6 branches as well?
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-05-10 10:33
See also about a real bug found thanks to these warnings.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-05-10 18:14
I think it safer to silence this kind of warnings in 3.7 and 3.6. PR 6757 does this.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-05-25 10:16
New changeset ef91ddeae79497fac25545dd68ee55a5a3c60e8d by Serhiy Storchaka in branch '3.7': bpo-33012: Add -Wno-cast-function-type for gcc 8. (GH-6757) https://github.com/python/cpython/commit/ef91ddeae79497fac25545dd68ee55a5a3c60e8d
Author: miss-islington (miss-islington)
Date: 2018-05-25 11:03
New changeset 20b797dafa149afcdd7b64e489eb8ea1386d8eb4 by Miss Islington (bot) in branch '3.6': bpo-33012: Add -Wno-cast-function-type for gcc 8. (GH-6757) https://github.com/python/cpython/commit/20b797dafa149afcdd7b64e489eb8ea1386d8eb4
Author: Xavier de Gaye (xdegaye) *
Date: 2018-05-26 15:16
I propose to enhance the changes made by PR 6748 and PR 6749 so that gcc 8 triggers a warning when the function type of a PyMethodDef element does not match its flags by using a macro (see below) that casts the function first to the function type corresponding to those flags and then to (void *) as done in those PRs to silence the warning when cast to PyCFunction. This would allow detecting bugs such as the one found in .
With the following patch (it is just an example) gcc 8 would emit a warning if bisect_right() does not match the type (in the sense defined by -Wcast-function-type) of PyCFunctionWithKeywords:
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
index 831e10aa60..85fb0c188e 100644
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -216,15 +216,14 @@ If x is already in a, insert it to the left of the leftmost x.\n
Optional args lo (default 0) and hi (default len(a)) bound the\n
slice of a to be searched.\n");
+#define SET_METH_VARARGS_KEYWORDS(func) \
- (PyCFunction)(void *)(PyCFunctionWithKeywords)(func), METH_VARARGS|METH_KEYWORDS
- static PyMethodDef bisect_methods[] = {
- {"bisect_right", (PyCFunction)bisect_right,
METH_VARARGS|METH_KEYWORDS, bisect_right_doc},
- {"insort_right", (PyCFunction)insort_right,
METH_VARARGS|METH_KEYWORDS, insort_right_doc},
- {"bisect_left", (PyCFunction)bisect_left,
METH_VARARGS|METH_KEYWORDS, bisect_left_doc},
- {"insort_left", (PyCFunction)insort_left,
METH_VARARGS|METH_KEYWORDS, insort_left_doc},
- {"bisect_right", SET_METH_VARARGS_KEYWORDS(bisect_right), bisect_right_doc},
- {"insort_right", SET_METH_VARARGS_KEYWORDS(insort_right), insort_right_doc},
- {"bisect_left", SET_METH_VARARGS_KEYWORDS(bisect_left), bisect_left_doc},
- {"insort_left", SET_METH_VARARGS_KEYWORDS(insort_left), insort_left_doc}, {NULL, NULL} /* sentinel */ };
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-05-26 17:25
Great idea!
But the problem is that additional flags can be used, e.g. METH_CLASS.
Author: Xavier de Gaye (xdegaye) *
Date: 2018-05-27 14:27
But the problem is that additional flags can be used, e.g. METH_CLASS.
Right, https://docs.python.org/3/c-api/structures.html says: "The individual flags indicate either a calling convention or a binding convention". This may be overcome by introducing another macro with 2 arguments, the second argument being used to set the binding convention flag:
#define SET_METH_VARARGS_KEYWORDS_FLAG(func, flag)
(PyCFunction)(void *)(PyCFunctionWithKeywords)func, METH_VARARGS|METH_KEYWORDS|flag
#define SET_METH_VARARGS_KEYWORDS(func) SET_METH_VARARGS_KEYWORDS_FLAG(func, 0x0000)
The refactoring would be quite large though.
Author: Antti Haapala (ztane) *
Date: 2018-05-28 03:53
Well, there's only one problem with casting to void *: while converting the function pointer to another is standard-compliant, and GCC is being just hypersensitive here, casting a function pointer to void * isn't, though it is a common extension (http://port70.net/~nsz/c/c11/n1570.html#J.5.7).
Pedantically the correct way is to cast to a function pointer with no prototype (empty parentheses) and from that to the target type. See for example. See for example https://godbolt.org/g/FdPdUj
Author: Siddhesh Poyarekar (siddhesh) *
Date: 2018-05-28 06:31
Pedantically the correct way is to cast to a function pointer with no prototype (empty parentheses) and from that to the target type. See for example. See for example https://godbolt.org/g/FdPdUj
This is one way that the gcc diagnostics explicitly allow in addition to variable arguments like so: https://godbolt.org/g/Dtb4fv
Author: (yan12125) *
Date: 2018-05-28 07:12
There are still quite a few similar warnings on git-master. Do they indicate the same problem or should I open new issues?
For example:
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I. -I./Include -DPy_BUILD_CORE -o Objects/bytearrayobject.o Objects/bytearrayobject.c In file included from Objects/bytearrayobject.c:96: Objects/clinic/bytearrayobject.c.h:677:23: warning: cast between incompatible function types from ‘PyObject * ()(PyByteArrayObject , PyObject * const, Py_ssize_t)’ {aka ‘struct _object * ()(struct , struct _object * const, long int)’} to ‘PyObject * (*)(PyObject *, PyObject )’ {aka ‘struct _object * ()(struct object *, struct object *)’} [-Wcast-function-type] {"reduce_ex", (PyCFunction)bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc}, ^ Objects/bytearrayobject.c:2136:5: note: in expansion of macro ‘BYTEARRAY_REDUCE_EX_METHODDEF’ BYTEARRAY_REDUCE_EX_METHODDEF ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm using GCC 8.1.0 on Arch Linux.
Author: Xavier de Gaye (xdegaye) *
Date: 2018-05-28 14:23
Pedantically the correct way is to cast to a function pointer with no prototype (empty parentheses)
Thanks for raising this point Antti. This is hinted at by the gcc 8 documentation on -Wcast-function-type: "The function type void (*) (void) is special and matches everything, which can be used to suppress this warning" [1]. One cannot use empty parentheses though as this raises -Wstrict-prototypes on Python builds with gcc and -Wcast-function-type with gcc 8.
So (void ) may be replaced with (void () (void)) in my previous code snippets and also in PR 6748 and PR 6749 (I just checked my code).
[1] https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Warning-Options.html#Warning-Options
Author: Xavier de Gaye (xdegaye) *
Date: 2018-05-28 14:26
There are still quite a few similar warnings on git-master. Do they indicate the same problem or should I open new issues?
This is the same issue, the warning line ends with [-Wcast-function-type].
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-06-03 12:32
The problem with invalid function signatures was initially reported in old .
Author: Terry J. Reedy (terry.reedy) *
Date: 2018-09-23 20:46
If I click the link for PR 6748, I see a page with "We went looking everywhere, but couldn’t find those commits." Maybe the PR needs to be refreshed or closed and maybe reopened. PR 6749 looks normal.
Author: STINNER Victor (vstinner) *
Date: 2018-10-15 13:29
I marked bpo-34992 as a duplicate of this issue:
I use Fedora 28 and gcc (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)
and I get a lot of warnings, with the standard config of Python (./configure)
Objects/call.c: In function '_PyMethodDef_RawFastCallDict': Objects/call.c:515:24: warning: cast between incompatible function types from 'PyCFunction' {aka 'struct _object * (*)(struct _object *, struct _object )'} to 'PyObject * ()(PyObject *, PyObject , PyObject )' {aka 'struct _object * ()(struct _object , struct _object , struct _object )'} [-Wcast-function-type] result = ((PyCFunctionWithKeywords)meth) (self, argstuple, kwargs); ^ Objects/call.c:530:20: warning: cast between incompatible function types from 'PyCFunction' {aka 'struct _object * ()(struct _object , struct _object )'} to 'PyObject * ()(PyObject , PyObject * const, Py_ssize_t)' {aka 'struct _object * ()(struct _object , struct _object * const, long int)'} [-Wcast-function-type] result = ((_PyCFunctionFast)meth) (self, args, nargs); ^ Objects/call.c:538:49: warning: cast between incompatible function types from 'PyCFunction' {aka 'struct _object * ()(struct _object *, struct _object )'} to 'PyObject * ()(PyObject , PyObject * const, Py_ssize_t, PyObject )' {aka 'struct _object * ()(struct _object , struct _object * const, long int, struct _object *)'} [-Wcast-function-type] _PyCFunctionFastWithKeywords fastmeth = (_PyCFunctionFastWithKeywords)meth;
....
+- 827 warnings
Author: Michael Airey (resmord)
Date: 2018-10-25 05:06
Try this - https://github.com/siddhesh/cpython/tree/func-cast
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 09:27
New changeset 4a934d490fac779d8954a8292369c4506bab23fa by Serhiy Storchaka in branch 'master': bpo-33012: Fix invalid function cast warnings with gcc 8 in Argument Clinic. (GH-6748) https://github.com/python/cpython/commit/4a934d490fac779d8954a8292369c4506bab23fa
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 11:05
New changeset 81524022d0c0df7a41f9b2b2df41e2ebe140e610 by Serhiy Storchaka in branch 'master': bpo-33012: Fix signatures of METH_NOARGS funstions. (GH-10736) https://github.com/python/cpython/commit/81524022d0c0df7a41f9b2b2df41e2ebe140e610
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 11:27
New changeset 62be74290aca26d16f3f55ece7ff6dad14e60e8d by Serhiy Storchaka in branch 'master': bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749) https://github.com/python/cpython/commit/62be74290aca26d16f3f55ece7ff6dad14e60e8d
Author: STINNER Victor (vstinner) *
Date: 2018-11-27 14:56
New changeset 62be74290aca26d16f3f55ece7ff6dad14e60e8d by Serhiy Storchaka in branch 'master': bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)
I still get something 100 warnings with GCC 8.2.1 on Fedora 29. I wrote PR 10744 to add a macro to cast a function pointer.
I chose to add a macro, so it will be easier to spot where we cast function pointers and change the implementation (cast) if needed at a single place.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 18:27
New changeset ad8ac54aa3d2323bdb5feb5e858a922840358187 by Serhiy Storchaka in branch '3.7': bpo-33012: Fix signatures of METH_NOARGS functions. (GH-10736) (GH-10748) https://github.com/python/cpython/commit/ad8ac54aa3d2323bdb5feb5e858a922840358187
Author: miss-islington (miss-islington)
Date: 2018-11-27 18:51
New changeset d5c8bd8e4cc04873254f0bd38895a6479c23c8aa by Miss Islington (bot) in branch '3.6': bpo-33012: Fix signatures of METH_NOARGS functions. (GH-10736) (GH-10748) https://github.com/python/cpython/commit/d5c8bd8e4cc04873254f0bd38895a6479c23c8aa
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 19:34
New changeset 1c607155c9e363489036ae6258b165a3fae75134 by Serhiy Storchaka in branch 'master': bpo-33012: Fix more invalid function cast warnings with gcc 8. (GH-10751) https://github.com/python/cpython/commit/1c607155c9e363489036ae6258b165a3fae75134
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2018-11-27 19:45
Only one function cast warning is left, and it is a separate issue: .
Author: miss-islington (miss-islington)
Date: 2018-11-29 14:27
New changeset 1659c08d5d17357597f220c4d297b19e7a59737c by Miss Islington (bot) in branch '3.7': bpo-33012: Fix more invalid function cast warnings with gcc 8. (GH-10751) https://github.com/python/cpython/commit/1659c08d5d17357597f220c4d297b19e7a59737c
Author: STINNER Victor (vstinner) *
Date: 2018-11-29 14:49
New changeset 77000bbb104021b89368b9f7cab6f1417794e348 by Victor Stinner in branch '3.6': bpo-33012: Fix more invalid function cast warnings with gcc 8. (GH-10751) (GH-10796) https://github.com/python/cpython/commit/77000bbb104021b89368b9f7cab6f1417794e348
Author: STINNER Victor (vstinner) *
Date: 2019-03-05 14:58
I marked bpo-36197 as a duplicate of this issue:
""" gcc -pthread -c -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -g -Og -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Objects/memoryobject.o Objects/memoryobject.c Objects/memoryobject.c:3112:21: warning: cast between incompatible function types from 'PyObject * (*)(PyMemoryViewObject *, PyObject *, PyObject )' {aka 'struct _object * ()(struct *, struct _object *, struct _object )'} to 'PyObject * ()(PyObject *, PyObject )' {aka 'struct _object * ()(struct _object *, struct _object *)'} [-Wcast-function-type] {"tobytes", (PyCFunction)memory_tobytes, METH_VARARGS|METH_KEYWORDS, memory_tobytes_doc},
I am preparing a small PR for this issue. """
=> PR 12179
Author: STINNER Victor (vstinner) *
Date: 2019-03-05 15:10
New changeset 359a2f3daba49fde0d3a07fb3c7a8b051c450d08 by Victor Stinner (Stéphane Wirtel) in branch 'master': bpo-33012: Fix compilation warnings in memoryobject.c and _collectionsmodule.c (GH-12179) https://github.com/python/cpython/commit/359a2f3daba49fde0d3a07fb3c7a8b051c450d08
Author: Andreas Schneider (asn) *
Date: 2019-04-30 14:53
Looking at:
https://github.com/python/cpython/commit/359a2f3daba49fde0d3a07fb3c7a8b051c450d08
This is not fixing the underlying issue but hiding it. The right fix would be to use a union for ml_meth providing members for the 3 different function. So the developer could assign them correctly and the compiler would warn if he would do something wrong. Casting to (void *) is just hiding the problem not fixing it!
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2019-04-30 15:38
Yes, and this particular case was fixed in adfffc7343ce7ebc88ec734a803d3247ba8927fb.
Author: Andreas Schneider (asn) *
Date: 2019-04-30 15:45
And how do you deal with METH_VARARGS|METH_KEYWORDS functions which have 3 arguments?
PyObject* myfunc(PyObject *py_obj, PyObject *args, PyObject *kwargs)
Author: STINNER Victor (vstinner) *
Date: 2020-03-12 12:38
FYI I modified SystemError("bad call flags") error message to include the method name in bpo-39884.
History
Date
User
Action
Args
2022-04-11 14:58:58
admin
set
github: 77193
2020-03-12 12:38:56
vstinner
set
messages: +
2019-08-14 05:33:34
ZackerySpytz
set
pull_requests: + <pull%5Frequest14986>
2019-04-30 15:45:55
asn
set
messages: +
2019-04-30 15:38:33
serhiy.storchaka
set
messages: +
2019-04-30 14:53:50
asn
set
nosy: + asn
messages: +
2019-03-05 15:10:56
vstinner
set
messages: +
2019-03-05 14:58:48
matrixise
set
pull_requests: + <pull%5Frequest12175>
2019-03-05 14:58:30
vstinner
set
messages: +
2019-03-05 14:57:52
vstinner
link
2018-11-29 14:49:24
vstinner
set
messages: +
2018-11-29 14:27:55
miss-islington
set
messages: +
2018-11-29 14:22:54
vstinner
set
pull_requests: + <pull%5Frequest10043>
2018-11-29 14:10:05
miss-islington
set
pull_requests: + <pull%5Frequest10042>
2018-11-27 19:45:30
serhiy.storchaka
set
status: open -> closed
resolution: fixed
messages: +
stage: patch review -> resolved
2018-11-27 19:34:36
serhiy.storchaka
set
messages: +
2018-11-27 18:51:11
miss-islington
set
messages: +
2018-11-27 18:50:14
serhiy.storchaka
set
pull_requests: + <pull%5Frequest9999>
2018-11-27 18:28:23
miss-islington
set
pull_requests: + <pull%5Frequest9998>
2018-11-27 18:27:50
serhiy.storchaka
set
messages: +
2018-11-27 17:44:28
serhiy.storchaka
set
pull_requests: + <pull%5Frequest9996>
2018-11-27 14:56:59
vstinner
set
messages: +
2018-11-27 14:55:02
vstinner
set
pull_requests: + <pull%5Frequest9991>
2018-11-27 11:27:34
serhiy.storchaka
set
messages: +
2018-11-27 11:05:06
serhiy.storchaka
set
messages: +
2018-11-27 10:34:05
serhiy.storchaka
set
pull_requests: + <pull%5Frequest9983>
2018-11-27 09:27:40
serhiy.storchaka
set
messages: +
2018-10-25 05:06:25
resmord
set
nosy: + resmord
messages: +
2018-10-24 19:42:52
gregory.p.smith
set
nosy: + gregory.p.smith
versions: + Python 3.7
2018-10-15 13:29:52
vstinner
set
messages: +
2018-10-15 13:29:22
vstinner
link
2018-09-23 20:46:24
terry.reedy
set
nosy: + terry.reedy
messages: +
2018-06-03 12:32:52
serhiy.storchaka
set
messages: +
2018-05-28 14:26:53
xdegaye
set
messages: +
2018-05-28 14:23:22
xdegaye
set
messages: +
2018-05-28 07:12:54
yan12125
set
nosy: + yan12125
messages: +
2018-05-28 06:31:40
siddhesh
set
messages: +
2018-05-28 03:53:34
ztane
set
messages: +
2018-05-27 14:27:52
xdegaye
set
messages: +
2018-05-26 17:25:31
serhiy.storchaka
set
messages: +
2018-05-26 15:16:28
xdegaye
set
nosy: + xdegaye
messages: +
2018-05-25 11:08:06
eitan.adler
set
nosy: + eitan.adler
2018-05-25 11:03:04
miss-islington
set
nosy: + miss-islington
messages: +
2018-05-25 10:17:09
miss-islington
set
pull_requests: + <pull%5Frequest6751>
2018-05-25 10:16:54
serhiy.storchaka
set
messages: +
2018-05-10 18:14:01
serhiy.storchaka
set
messages: +
2018-05-10 18:12:20
serhiy.storchaka
set
pull_requests: + <pull%5Frequest6444>
2018-05-10 12:45:34
pmpp
set
nosy: + pmpp
2018-05-10 10:33:43
serhiy.storchaka
set
messages: +
2018-05-10 10:31:15
cstratak
set
messages: +
2018-05-10 10:28:54
serhiy.storchaka
set
messages: +
2018-05-10 10:23:03
serhiy.storchaka
set
pull_requests: + <pull%5Frequest6437>
2018-05-10 10:22:47
serhiy.storchaka
set
pull_requests: + <pull%5Frequest6436>
2018-04-30 12:35:16
serhiy.storchaka
set
messages: +
2018-04-30 08:24:09
serhiy.storchaka
set
pull_requests: + <pull%5Frequest6348>
2018-04-30 08:07:23
siddhesh
set
messages: +
2018-04-30 08:02:19
vstinner
set
nosy: + vstinner
messages: +
2018-04-29 18:59:35
serhiy.storchaka
set
messages: +
2018-04-09 10:41:33
siddhesh
set
messages: +
2018-04-05 00:13:46
martin.panter
set
messages: +
2018-04-02 03:52:53
martin.panter
set
nosy: + martin.panter
messages: +
2018-03-15 15:55:27
siddhesh
set
messages: +
2018-03-15 15:54:03
siddhesh
set
messages: +
2018-03-15 15:27:14
ztane
set
messages: +
2018-03-15 12:10:16
serhiy.storchaka
set
dependencies: + Questionable code in OrderedDict definition
2018-03-15 12:07:38
siddhesh
set
messages: +
2018-03-15 11:33:22
ztane
set
nosy: + ztane
messages: +
2018-03-08 15:11:06
siddhesh
set
keywords: + patch
stage: patch review
pull_requests: + <pull%5Frequest5792>
2018-03-06 11:38:00
cstratak
set
nosy: + cstratak
messages: +
2018-03-06 11:32:34
serhiy.storchaka
set
nosy: + serhiy.storchaka
messages: +
versions: + Python 3.8
2018-03-06 11🔞13
siddhesh
create