-
- Downloads
gh-89653: PEP 670: Convert macros to functions (#99843)
Convert macros to static inline functions to avoid macro pitfalls, like duplication of side effects: * DK_ENTRIES() * DK_UNICODE_ENTRIES() * PyCode_GetNumFree() * PyFloat_AS_DOUBLE() * PyInstanceMethod_GET_FUNCTION() * PyMemoryView_GET_BASE() * PyMemoryView_GET_BUFFER() * PyMethod_GET_FUNCTION() * PyMethod_GET_SELF() * PySet_GET_SIZE() * _PyHeapType_GET_MEMBERS() Changes: * PyCode_GetNumFree() casts PyCode_GetNumFree.co_nfreevars from int to Py_ssize_t to be future proof, and because Py_ssize_t is commonly used in the C API. * PyCode_GetNumFree() doesn't cast its argument: the replaced macro already required the exact type PyCodeObject*. * Add assertions in some functions using "CAST" macros to check the arguments type when Python is built with assertions (debug build). * Remove an outdated comment in unicodeobject.h.
Showing
- Include/cpython/classobject.h 24 additions, 10 deletionsInclude/cpython/classobject.h
- Include/cpython/code.h 6 additions, 1 deletionInclude/cpython/code.h
- Include/cpython/floatobject.h 8 additions, 2 deletionsInclude/cpython/floatobject.h
- Include/cpython/memoryobject.h 11 additions, 2 deletionsInclude/cpython/memoryobject.h
- Include/cpython/setobject.h 7 additions, 2 deletionsInclude/cpython/setobject.h
- Include/cpython/unicodeobject.h 0 additions, 2 deletionsInclude/cpython/unicodeobject.h
- Include/internal/pycore_dict.h 15 additions, 6 deletionsInclude/internal/pycore_dict.h
- Include/internal/pycore_object.h 3 additions, 2 deletionsInclude/internal/pycore_object.h
Loading
Please register or sign in to comment