Skip to content

Avoid DeprecationWarning for _pack_ without _layout_ when there are not bit-fields? #133800

Open
@seberg

Description

@seberg

Bug report

Bug description:

New Python versions give a DeprecationWarning for struct definitions that use _pack_ = True but do not specify the _layout_.

In a sense a new feature, but as I believe this is only relevant for bit-fields: wouldn't it make sense to allow leaving _layout_ unspecified when the struct contains no bitfields?
(I suppose that means giving it some default, such as the system native layout.)

The context is just seeing this in NumPy where bit-fields are not used so I was wondering: numpy/numpy#28926.
Adding the _layout_ isn't a problem of course, but if the no-bitfield case is common (not sure) it may be nice to not be forced to "decide" on an irrelevant _layout_ (or act up on the DeprecationWarning)?

Another question that comes to mind is that _layout_ = "native" or so seems potentially useful.

CPython versions tested on:

3.14

Operating systems tested on:

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions