Message416354
The problem in the example you give is the need for the cast in the first place. If `func` were a `PyCFunctionObject *` instead of a `PyObject *`, then there would be no cast.
Making the casts explicit serves as a reminder that a type check is needed.
```
PyObject *func = ...;
int flags = PyCFunction_GET_FLAGS(func);
```
is dangerous.
```
PyObject *obj = ...;
if (PyCFunction_Check(obj)) {
PyCFunctionObject *func = (PyCFunctionObject *)obj;
int flags = func->m_ml->ml_flags;
```
is safe. |
|
Date |
User |
Action |
Args |
2022-03-30 13:20:34 | Mark.Shannon | set | recipients:
+ Mark.Shannon, vstinner |
2022-03-30 13:20:34 | Mark.Shannon | set | messageid: <1648646434.7.0.019781167108.issue47164@roundup.psfhosted.org> |
2022-03-30 13:20:34 | Mark.Shannon | link | issue47164 messages |
2022-03-30 13:20:34 | Mark.Shannon | create | |
|