Avoid DeprecationWarning for `_pack_` without `_layout_` when there are not bit-fields?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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: https://github.com/numpy/numpy/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the DeprecationWarning in Python 3.14 for a struct definition using _pack_ = True without _layout_, focusing on the no-bit-fields case described in the report. Review the related ctypes behavior and the NumPy issue linked in the report; done requires an agreed layout default or a clear decision that the warning remains necessary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100