gh-131747: ctypes: Deprecate _pack_ implicitly setting _layout_ = 'ms… · python/cpython@59f78d7

GitHub

@@ -125,18 +125,21 @@ class Nested(Structure):

125125classPacked1(Structure):

126126_fields_= [('a', c_int8), ('b', c_int64)]

127127_pack_=1

128+_layout_='ms'

128129129130130131@register()

131132classPacked2(Structure):

132133_fields_= [('a', c_int8), ('b', c_int64)]

133134_pack_=2

135+_layout_='ms'

134136135137136138@register()

137139classPacked3(Structure):

138140_fields_= [('a', c_int8), ('b', c_int64)]

139141_pack_=4

142+_layout_='ms'

140143141144142145@register()

@@ -155,6 +158,7 @@ def _maybe_skip():

155158156159_fields_= [('a', c_int8), ('b', c_int64)]

157160_pack_=8

161+_layout_='ms'

158162159163@register()

160164classX86_32EdgeCase(Structure):

@@ -366,6 +370,7 @@ class Example_gh_95496(Structure):

366370@register()

367371classExample_gh_84039_bad(Structure):

368372_pack_=1

373+_layout_='ms'

369374_fields_= [("a0", c_uint8, 1),

370375 ("a1", c_uint8, 1),

371376 ("a2", c_uint8, 1),

@@ -380,6 +385,7 @@ class Example_gh_84039_bad(Structure):

380385@register()

381386classExample_gh_84039_good_a(Structure):

382387_pack_=1

388+_layout_='ms'

383389_fields_= [("a0", c_uint8, 1),

384390 ("a1", c_uint8, 1),

385391 ("a2", c_uint8, 1),

@@ -392,13 +398,15 @@ class Example_gh_84039_good_a(Structure):

392398@register()

393399classExample_gh_84039_good(Structure):

394400_pack_=1

401+_layout_='ms'

395402_fields_= [("a", Example_gh_84039_good_a),

396403 ("b0", c_uint16, 4),

397404 ("b1", c_uint16, 12)]

398405399406@register()

400407classExample_gh_73939(Structure):

401408_pack_=1

409+_layout_='ms'

402410_fields_= [("P", c_uint16),

403411 ("L", c_uint16, 9),

404412 ("Pro", c_uint16, 1),

@@ -419,6 +427,7 @@ class Example_gh_86098(Structure):

419427@register()

420428classExample_gh_86098_pack(Structure):

421429_pack_=1

430+_layout_='ms'

422431_fields_= [("a", c_uint8, 8),

423432 ("b", c_uint8, 8),

424433 ("c", c_uint32, 16)]

@@ -528,7 +537,7 @@ def dump_ctype(tp, struct_or_union_tag='', variable_name='', semi=''):

528537pushes.append(f'#pragma pack(push, {pack})')

529538pops.append(f'#pragma pack(pop)')

530539layout=getattr(tp, '_layout_', None)

531-iflayout=='ms'orpack:

540+iflayout=='ms':

532541# The 'ms_struct' attribute only works on x86 and PowerPC

533542requires.add(

534543'defined(MS_WIN32) || ('