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 Charles Machalow
Recipients Charles Machalow, amaury.forgeotdarc, belopolsky, meador.inge
Date 2017-03-08.07:23:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488957840.07.0.509999079709.issue29753@psf.upfronthosting.co.za>
In-reply-to
Content
Some more debug with print statements in the c code seems to confirm my suspicion:

bitsize, pfield_size, bitofs, dict->size prints were added just above the if chain to determine fieldtype and fieldtype was just after that if chain. That code looks something like this:

printf("bitsize: %d\n" , (int)bitsize);
printf("pfield_size: %u\n", (size_t)*pfield_size);
printf("bitofs: %d\n", (int)*pbitofs);
printf("dict->size: %d\n", (int)dict->size);
    if (bitsize /* this is a bitfield request */
        && *pfield_size /* we have a bitfield open */
#ifdef MS_WIN32
        /* MSVC, GCC with -mms-bitfields */
        && dict->size * 8 == *pfield_size
#else
        /* GCC */
        && dict->size * 8 <= *pfield_size
#endif
        && (*pbitofs + bitsize) <= *pfield_size) {
        /* continue bit field */
        fieldtype = CONT_BITFIELD;
#ifndef MS_WIN32
    } else if (bitsize /* this is a bitfield request */
        && *pfield_size /* we have a bitfield open */
        && dict->size * 8 >= *pfield_size
        && (*pbitofs + bitsize) <= dict->size * 8) {
        /* expand bit field */
        fieldtype = EXPAND_BITFIELD;
#endif
    } else if (bitsize) {
        /* start new bitfield */
        fieldtype = NEW_BITFIELD;
        *pbitofs = 0;
        *pfield_size = dict->size * 8;
    } else {
        /* not a bit field */
        fieldtype = NO_BITFIELD;
        *pbitofs = 0;
        *pfield_size = 0;
    }

printf("Fieldtype: %d\n------\n", fieldtype);

And the run with the custom-built Python 2.7.13:

>>> from test import *
bitsize: 0
pfield_size: 0
bitofs: 255918304
dict->size: 2
Fieldtype: 0
------
bitsize: 9
pfield_size: 0
bitofs: 0
dict->size: 2
Fieldtype: 1
------
bitsize: 1
pfield_size: 16
bitofs: 9
dict->size: 2
Fieldtype: 2
------
bitsize: 1
pfield_size: 16
bitofs: 10
dict->size: 2
Fieldtype: 2
------
bitsize: 1
pfield_size: 16
bitofs: 11
dict->size: 2
Fieldtype: 2
------
bitsize: 1
pfield_size: 16
bitofs: 12
dict->size: 2
Fieldtype: 2
------
bitsize: 3
pfield_size: 16
bitofs: 13
dict->size: 2
Fieldtype: 2
------
bitsize: 10
pfield_size: 16
bitofs: 16
dict->size: 4
Fieldtype: 3
------
bitsize: 20
pfield_size: 32
bitofs: 26
dict->size: 4
Fieldtype: 1
------
bitsize: 2
pfield_size: 32
bitofs: 20
dict->size: 4
Fieldtype: 2
------
10
>>> MyStructure.P
<Field type=c_ushort, ofs=0, size=2>
>>> MyStructure.T
<Field type=c_uint, ofs=2:16, bits=10>
>>> MyStructure.R
<Field type=c_ushort, ofs=2:13, bits=3>
>>> MyStructure.P
<Field type=c_ushort, ofs=0, size=2>
>>> MyStructure.L
<Field type=c_ushort, ofs=2:0, bits=9>
>>> MyStructure.Pro
<Field type=c_ushort, ofs=2:9, bits=1>
>>> MyStructure.R
<Field type=c_ushort, ofs=2:13, bits=3>
>>> MyStructure.T
<Field type=c_uint, ofs=2:16, bits=10>
>>> MyStructure.C
<Field type=c_uint, ofs=6:0, bits=20>
History
Date User Action Args
2017-03-08 07:24:00Charles Machalowsetrecipients: + Charles Machalow, amaury.forgeotdarc, belopolsky, meador.inge
2017-03-08 07:24:00Charles Machalowsetmessageid: <1488957840.07.0.509999079709.issue29753@psf.upfronthosting.co.za>
2017-03-08 07:24:00Charles Machalowlinkissue29753 messages
2017-03-08 07:23:59Charles Machalowcreate