Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Nick Coghlan
Terry Reedy wrote: > Roger Binns wrote: > >> The problem is that unless you are clairvoyant you have no way of >> knowing about this change. Even in rc3 the documentation shows the old >> (wrong) way: >> >> http://docs.python.org/dev/3.0/extending/newtypes.html >> >> PyObject_HEAD_INIT is docum

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Terry Reedy
Roger Binns wrote: The problem is that unless you are clairvoyant you have no way of knowing about this change. Even in rc3 the documentation shows the old (wrong) way: http://docs.python.org/dev/3.0/extending/newtypes.html PyObject_HEAD_INIT is documented: http://docs.python.org/dev/3.0

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 M.-A. Lemburg wrote: > Starting with Python 3, you have to use PyVarObject_HEAD_INIT() > on PyVarObjects and PyObject_HEAD_INIT() on PyObjects. I don't > see the problem. It's just another change to remember when porting > to Python 3. The problem is

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread M.-A. Lemburg
On 2008-11-21 19:36, Adam Olsen wrote: > On Fri, Nov 21, 2008 at 10:53 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: >> Yes, it's a different way of writing and accessing the resp. fields. >> No, it's not a different memory layout. >> Yes, this is binary compatible. >> No, this is not going to help

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 M.-A. Lemburg wrote: > You might get warnings (esp. from GCC), but I have yet to see a compiler > that doesn't map the above to the same memory. They don't map the same as Adam showed. Your fields end up off by one which is why the compiler is giving

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Adam Olsen
On Fri, Nov 21, 2008 at 10:53 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > On 2008-11-21 18:36, Adam Olsen wrote: >> On Fri, Nov 21, 2008 at 7:14 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: >>> On 2008-11-20 20:34, Roger Binns wrote: M.-A. Lemburg wrote: > Whether you write: > {PyOb

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread M.-A. Lemburg
On 2008-11-21 18:36, Adam Olsen wrote: > On Fri, Nov 21, 2008 at 7:14 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: >> On 2008-11-20 20:34, Roger Binns wrote: >>> M.-A. Lemburg wrote: Whether you write: {PyObject_HEAD_INIT(0), 0, ... or {PyVarObject_HEAD_INIT(0, 0), ... for

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread Adam Olsen
On Fri, Nov 21, 2008 at 7:14 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > On 2008-11-20 20:34, Roger Binns wrote: >> M.-A. Lemburg wrote: >>> Whether you write: >> >>> {PyObject_HEAD_INIT(0), 0, ... >> >>> or >> >>> {PyVarObject_HEAD_INIT(0, 0), ... >> >>> for your type definition doesn't really

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-21 Thread M.-A. Lemburg
On 2008-11-20 20:34, Roger Binns wrote: > M.-A. Lemburg wrote: >> Whether you write: > >> {PyObject_HEAD_INIT(0), 0, ... > >> or > >> {PyVarObject_HEAD_INIT(0, 0), ... > >> for your type definition doesn't really make much difference. > > Actually in Py 3 it does. If you use the former (whic

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-20 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 M.-A. Lemburg wrote: > Whether you write: > > {PyObject_HEAD_INIT(0), 0, ... > > or > > {PyVarObject_HEAD_INIT(0, 0), ... > > for your type definition doesn't really make much difference. Actually in Py 3 it does. If you use the former (which is

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-20 Thread M.-A. Lemburg
On 2008-11-14 22:15, Roger Binns wrote: > My confusion was because I though that the HEAD for the data structure > had to use the same corresponding HEAD_INIT in the type. So for > whatever reason the PyTypeObject is declared as a var object which is > why the var HEAD_INIT is needed. > > It stil

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Greg Ewing
Roger Binns wrote: Obviously the Python 3 documentation and examples need to be updated. Also why not remove PyObject_HEAD_INIT from Python 3 headers so that if it is used then the compile fails? Is there some reason not to define PyObject_HEAD_INIT so that it expands into the appropriate PyVa

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 My confusion was because I though that the HEAD for the data structure had to use the same corresponding HEAD_INIT in the type. So for whatever reason the PyTypeObject is declared as a var object which is why the var HEAD_INIT is needed. It still loo

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Martin v. Löwis
Roger Binns wrote: > Martin v. Löwis wrote: >>> Also why not remove PyObject_HEAD_INIT from Python 3 headers so that if >>> it is used then the compile fails? >> It's still needed for non-var objects. > > Wouldn't a var object have PyVarObject_HEAD and a non-var object have > PyObject_HEAD? That'

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Martin v. Löwis wrote: >> Obviously the Python 3 documentation and examples need to be updated. > > I see - please submit a bug report. Yet another site that wants another login to report bugs. So someone else can report it. Roger -BEGIN PGP SI

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Martin v. Löwis wrote: >> Also why not remove PyObject_HEAD_INIT from Python 3 headers so that if >> it is used then the compile fails? > > It's still needed for non-var objects. Wouldn't a var object have PyVarObject_HEAD and a non-var object have P

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Martin v. Löwis
> Obviously the Python 3 documentation and examples need to be updated. I see - please submit a bug report. > Also why not remove PyObject_HEAD_INIT from Python 3 headers so that if > it is used then the compile fails? It's still needed for non-var objects. Regards, Martin _

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Martin v. Löwis wrote: >> It would seem that common practise, the examples and the documentation >> don't all match each other! > > I cannot parse this sentence. Py2 source: Uses PyObject_HEAD_INIT Py2 code compiled under Py3: Gives serious warning

Re: [Python-3000] PyObject_HEAD_INIT

2008-11-14 Thread Martin v. Löwis
Roger Binns wrote: > The Python 2.3 source shows the latter form being used almost > exclusively so at some point someone changed a lot of code. That's correct. I changed it for Python 3, for PEP 3123. > It would seem that common practise, the examples and the documentation > don't all match each

[Python-3000] PyObject_HEAD_INIT

2008-11-13 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Something has been baffling me and is still present in py3.0 -rc2. When initializing a (non-variable) PyTypeObject in Python 2, PyObject_HEAD_INIT is used. The docs for Python 3 still show that: http://docs.python.org/dev/3.0/extending/newtypes.ht