From d4d0b01433c76883d31a132d035d686828ad0321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 29 Apr 2007 13:46:08 +0000 Subject: [PATCH] Add Brett's suggested changes. --- pep-3123.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 =============================