INADA Naoki added the comment:

> but the code with PyObject_HEAD_INIT() doesn't look incompatible with Python 
> 3.

It's incompatible actually.

https://github.com/python/cpython/blob/2.7/Include/object.h

/* PyObject_HEAD defines the initial segment of every PyObject. */

#define PyObject_HEAD_INIT(type)        \
    _PyObject_EXTRA_INIT                \
    1, type,


https://github.com/python/cpython/blob/3.5/Include/object.h

#define PyObject_HEAD_INIT(type)        \
    { _PyObject_EXTRA_INIT              \
    1, type },


I noticed PyVarObject_HEAD_INIT is compatible, and simplified an extension I 
maintain.
https://github.com/PyMySQL/mysqlclient-python/commit/2feb5ed6850a3905edf0333e0cd11ea6218f0f4f


This small doc change helps people who writing Python 2's extension module now, 
and port it to Python 3 later.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29165>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to