python / python/cpython

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

Abierto
#133,800 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

extension-modules topic-ctypes type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo la DeprecationWarning en Python 3.14 para una definición de struct que use _pack_ = True sin _layout_, centrándote en el caso sin campos de bits descrito en el informe. Revisa el comportamiento relacionado de ctypes y el issue de NumPy enlazado en el informe; la tarea requiere que se acuerde un valor predeterminado para el layout o que se tome una decisión clara de que la advertencia sigue siendo necesaria.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
backend
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.