@@ -71,18 +71,6 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
7171 Py_DECREF (self );
7272 return NULL ;
7373 }
74-
75- #ifndef MS_WIN32
76- /* if we have a packed bitfield, calculate the minimum number of bytes we
77- need to fit it. otherwise use the specified size. */
78- if (pack && bitsize ) {
79- size = (bitsize - 1 ) / 8 + 1 ;
80- } else
81- #endif
82- size = dict -> size ;
83-
84- proto = desc ;
85-
8674 if (bitsize /* this is a bitfield request */
8775 && * pfield_size /* we have a bitfield open */
8876#ifdef MS_WIN32
@@ -99,26 +87,25 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
9987 } else if (bitsize /* this is a bitfield request */
10088 && * pfield_size /* we have a bitfield open */
10189 && dict -> size * 8 >= * pfield_size
102- /* if this is a packed bitfield, always expand it.
103- otherwise calculate if we need to expand it. */
104- && (((* pbitofs + bitsize ) <= dict -> size * 8 ) || pack )) {
90+ && (* pbitofs + bitsize ) <= dict -> size * 8 ) {
10591 /* expand bit field */
10692 fieldtype = EXPAND_BITFIELD ;
10793#endif
10894 } else if (bitsize ) {
10995 /* start new bitfield */
11096 fieldtype = NEW_BITFIELD ;
11197 * pbitofs = 0 ;
112- /* use our calculated size (size) instead of type size (dict->size),
113- which can be different for packed bitfields */
114- * pfield_size = size * 8 ;
98+ * pfield_size = dict -> size * 8 ;
11599 } else {
116100 /* not a bit field */
117101 fieldtype = NO_BITFIELD ;
118102 * pbitofs = 0 ;
119103 * pfield_size = 0 ;
120104 }
121105
106+ size = dict -> size ;
107+ proto = desc ;
108+
122109 /* Field descriptors for 'c_char * n' are be scpecial cased to
123110 return a Python string instead of an Array object instance...
124111 */
@@ -183,16 +170,10 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
183170 break ;
184171
185172 case EXPAND_BITFIELD :
186- /* increase the size if it is a packed bitfield.
187- EXPAND_BITFIELD should not be selected for non-packed fields if the
188- current size isn't already enough. */
189- if (pack )
190- size = (* pbitofs + bitsize - 1 ) / 8 + 1 ;
191-
192- * poffset += size - * pfield_size /8 ;
193- * psize += size - * pfield_size /8 ;
173+ * poffset += dict -> size - * pfield_size /8 ;
174+ * psize += dict -> size - * pfield_size /8 ;
194175
195- * pfield_size = size * 8 ;
176+ * pfield_size = dict -> size * 8 ;
196177
197178 if (big_endian )
198179 self -> size = (bitsize << 16 ) + * pfield_size - * pbitofs - bitsize ;
0 commit comments