[BUG]: Argument conversion in dispatcher assumes sequence protocol when casting to list[<something>]
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Área
- backend-api-design
Línea de trabajo
Comienza con el reproductor mínimo enlazado en el issue y confirma el fallo con pybind11 2.13.6. Traza la ruta de conversión de argumentos del dispatcher para las funciones sobrecargadas que aceptan un vector de instancias de una clase base y una instancia derivada. Done debería evitar la búsqueda no intencionada del protocolo de secuencia y proporcionar un resultado de conversión claro sin romper las conversiones válidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.6
Problem description
When a derived class implements __getitem__ and there exists an overloaded function that can accept a vector of base instances or the derived instance the argument conversion in the dispatcher logic will try to call derived.__getitem__.
If derived does not implement __len__ this will fail outright, otherwise derived.__getitem__ will be called with integer indices from 0 to len(derived). If derived.__getitem__ does not accept integers (e.g. because it mimics a map) this will also fail.
The resulting error message is extremely confusing because the trace will show that the execution failed at the function call but the message will say that __getitem__ was involved with derived and 0 but supported types are ...
A potential fix / workaround is to manually break the sequence protocol for derived by setting its tp_as_sequence->sq_item to NULL as this will cause it to fail PySequence_Check and avoid this conversion path entirely.
Adding noconvert to the vector argument does not help because this failure already happens in the initial non-converting pass in the dispatcher.
Reproducible example code
I have created a minimal example here: https://github.com/IljaManakov/pybind_arg_cast_issue_repro
Is this a regression? Put the last known working version here if it is.
Not a regression
- Lenguaje dominante
- C++
- Estrellas
- 18k
- Forks
- 2.3k
- Merge medio
- 5 d 7 h
- PR fusionados (30 d)
- 53
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pybind/pybind11
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 3 días
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
pybind/pybind11#5604 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 3 días
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
pybind/pybind11#747 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)Posiblemente ocupada @henryiii la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 3 días
Todos los issues de pybind/pybind11
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
patrick-hudson/put.gd-desktop#2044 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
uxlfoundation/oneDNN#6604 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Posiblemente ocupada @fmu1337 la tomó hoy. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
alliedmodders/sourcemod#2627 ·
Los mantenedores suelen responder en 1 día
-
`Number` enum is not exportedAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día