Add Brett's suggested changes.
This commit is contained in:
parent
a20cd09644
commit
d4d0b01433
17
pep-3123.txt
17
pep-3123.txt
|
@ -45,8 +45,8 @@ code has undefined behavior::
|
||||||
The problem here is that the storage is both accessed as
|
The problem here is that the storage is both accessed as
|
||||||
if it where struct PyObject, and as struct FooObject.
|
if it where struct PyObject, and as struct FooObject.
|
||||||
|
|
||||||
Historically, compilers did not cause any problems with this
|
Historically, compilers did not have any problems with this
|
||||||
code. However, modern compiler use that clause as an
|
code. However, modern compilers use that clause as an
|
||||||
optimization opportunity, finding that f->ob_refcnt and
|
optimization opportunity, finding that f->ob_refcnt and
|
||||||
o->ob_refcnt cannot possibly refer to the same memory, and
|
o->ob_refcnt cannot possibly refer to the same memory, and
|
||||||
that therefore the function should return 0, without having
|
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)
|
#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
|
Compatibility with Python 2.6
|
||||||
=============================
|
=============================
|
||||||
|
|
Loading…
Reference in New Issue