diff --git a/pep-3123.txt b/pep-3123.txt index 815f3b022..5108d9676 100644 --- a/pep-3123.txt +++ b/pep-3123.txt @@ -45,8 +45,8 @@ code has undefined behavior:: The problem here is that the storage is both accessed as if it where struct PyObject, and as struct FooObject. -Historically, compilers did not cause any problems with this -code. However, modern compiler use that clause as an +Historically, compilers did not have any problems with this +code. However, modern compilers use that clause as an optimization opportunity, finding that f->ob_refcnt and o->ob_refcnt cannot possibly refer to the same memory, and that therefore the function should return 0, without having @@ -110,7 +110,18 @@ ob_type, a macro:: #define Py_Type(o) (((PyObject*)o)->ob_type) -is added. +is added. E.g. the code blocks:: + + #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type) + + return func->ob_type->tp_name; + +needs to be changed to:: + + #define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type) + + return Py_Type(func)->tp_name; + Compatibility with Python 2.6 =============================