Barry Warsaw | 27 Apr 2012 17:38
Favicon

Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

Someone is trying to build gdb 7.4 with Python 3 and hit a problem with
Py_TPFLAGS_HAVE_ITER.  PEP 234 describes this flag, which no longer exists in
Python 3.  python3porting.com has precious little to say about Py_TPFLAGS
changes in Python 3.

When I did the dbus-python port, I found that Py_TPFLAGS_HAVE_WEAKREFS is both
unnecessary and undefined in Python 3.  Unfortunately, if you're going to
support both Python 2 and 3 with the same C code, you'll need to #ifdef that
away (since it's still required in Python 2).

My guess is that HAVE_ITER falls under the same recommendation, but I'm
looking for verification.  For now, I've added this to
https://wiki.ubuntu.com/Python/3

Cheers,
-Barry
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Amaury Forgeot d'Arc | 27 Apr 2012 17:48
Picon

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

Hi,

2012/4/27 Barry Warsaw <barry-+ZN9ApsXKcEdnm+yROfE0A@public.gmane.org>
Someone is trying to build gdb 7.4 with Python 3 and hit a problem with
Py_TPFLAGS_HAVE_ITER.  PEP 234 describes this flag, which no longer exists in
Python 3.  python3porting.com has precious little to say about Py_TPFLAGS
changes in Python 3.

When I did the dbus-python port, I found that Py_TPFLAGS_HAVE_WEAKREFS is both
unnecessary and undefined in Python 3.  Unfortunately, if you're going to
support both Python 2 and 3 with the same C code, you'll need to #ifdef that
away (since it's still required in Python 2).

My guess is that HAVE_ITER falls under the same recommendation, but I'm
looking for verification.  For now, I've added this to
https://wiki.ubuntu.com/Python/3

This is correct. I checked that everywhere Py_TPFLAGS_HAVE_ITER is used in Python2.7,
the corresponding code in Python 3 does as if this flag is always set.

So you could either #ifdef its usage, or simply put in some compatibility header file:
#if PY_MAJOR_VERSION >=3
#  define Py_TPFLAGS_HAVE_ITER 0
#endif


--
Amaury Forgeot d'Arc
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Barry Warsaw | 27 Apr 2012 19:06
Favicon

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

On Apr 27, 2012, at 05:48 PM, Amaury Forgeot d'Arc wrote:

>This is correct. I checked that everywhere Py_TPFLAGS_HAVE_ITER is used in
>Python2.7, the corresponding code in Python 3 does as if this flag is always
>set.
>
>So you could either #ifdef its usage, or simply put in some compatibility
>header file:
>#if PY_MAJOR_VERSION >=3
>#  define Py_TPFLAGS_HAVE_ITER 0
>#endif

Thanks for the confirmation.  I've been wondering if Benjamin might be
interested in contributions to `six` that address C compatibility.

-Barry
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 27 Apr 2012 23:23
Picon
Gravatar

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

On Fri, Apr 27, 2012 at 19:06, Barry Warsaw <barry@...> wrote:
> Thanks for the confirmation.  I've been wondering if Benjamin might be
> interested in contributions to `six` that address C compatibility.

A big header file with ifdefs would definitely help a lot of people, I
think. I only did the things I encountered, and I only did some small
things like zope.interface.

//Lennart
Barry Warsaw | 27 Apr 2012 23:29
Favicon

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

On Apr 27, 2012, at 11:23 PM, Lennart Regebro wrote:

>On Fri, Apr 27, 2012 at 19:06, Barry Warsaw <barry@...> wrote:
>> Thanks for the confirmation.  I've been wondering if Benjamin might be
>> interested in contributions to `six` that address C compatibility.
>
>A big header file with ifdefs would definitely help a lot of people, I
>think. I only did the things I encountered, and I only did some small
>things like zope.interface.

Cool, also Lennart, what's the best way to give you updates for
python3porting.com?

-Barry
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 27 Apr 2012 23:47
Picon
Gravatar

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

On Fri, Apr 27, 2012 at 23:29, Barry Warsaw <barry@...> wrote:
> Cool, also Lennart, what's the best way to give you updates for
> python3porting.com?

Not sure, I'm pondering the options. :-)

//Lennart
Benjamin Peterson | 27 Apr 2012 23:33
Favicon
Gravatar

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

2012/4/27 Barry Warsaw <barry <at> python.org>:
> On Apr 27, 2012, at 05:48 PM, Amaury Forgeot d'Arc wrote:
>
>>This is correct. I checked that everywhere Py_TPFLAGS_HAVE_ITER is used in
>>Python2.7, the corresponding code in Python 3 does as if this flag is always
>>set.
>>
>>So you could either #ifdef its usage, or simply put in some compatibility
>>header file:
>>#if PY_MAJOR_VERSION >=3
>>#  define Py_TPFLAGS_HAVE_ITER 0
>>#endif
>
> Thanks for the confirmation.  I've been wondering if Benjamin might be
> interested in contributions to `six` that address C compatibility.

Yes, absolutely. I haven't ported gobs of C code, so I'm not up on
what exactly people want.

--

-- 
Regards,
Benjamin
_______________________________________________
Python-porting mailing list
Python-porting <at> python.org
http://mail.python.org/mailman/listinfo/python-porting
Barry Warsaw | 28 Apr 2012 00:23
Favicon

Re: Py_TPFLAGS_HAVE_{WEAKREFS,ITER} in Python 3

On Apr 27, 2012, at 05:33 PM, Benjamin Peterson wrote:

>Yes, absolutely. I haven't ported gobs of C code, so I'm not up on
>what exactly people want.

I have a few big extensions under my belt, so I can take a first crack at it.
I guess the thing to do is to branch six on bitbucket.  I'll probably do that
next week.

-Barry
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting

Gmane