This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients docs@python, methane
Date 2017-01-05.06:47:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483598879.57.0.52341008423.issue29165@psf.upfronthosting.co.za>
In-reply-to
Content
https://docs.python.org/2.7/extending/newtypes.html#the-basics uses PyObject_HEAD_INIT for type object header.

static PyTypeObject noddy_NoddyType = {
    PyObject_HEAD_INIT(NULL)
    0,                         /*ob_size*/

This code isn't compatible with Python 3.  In Python 3, PyVarObject_HEAD_INIT is used instead.
https://docs.python.org/3.6/extending/newtypes.html#the-basics

static PyTypeObject noddy_NoddyType = {
    PyVarObject_HEAD_INIT(NULL, 0)

This code is compatible with Python 2.


This example code can be copy and pasted when creating new extension.
If people start writing Python 2 extension, and forward port it to Python 3,
this small incompatibility cause compile error.

Let's use more forward compatible and short code for example.
History
Date User Action Args
2017-01-05 06:47:59methanesetrecipients: + methane, docs@python
2017-01-05 06:47:59methanesetmessageid: <1483598879.57.0.52341008423.issue29165@psf.upfronthosting.co.za>
2017-01-05 06:47:59methanelinkissue29165 messages
2017-01-05 06:47:59methanecreate