python / python/cpython

ElementTree.iselement() returns true for the Element type

Abierto
#136,231 9 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

stdlib topic-XML type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

According to documentation, ElementTree.iselement() check if the argument is an element object.

But it returns true also for the Element type which has all attributes of an Element instance. The way how the Element class is defined in Python suggests that this may be intentional, but the intention was lost in the documentation.

There is also an example of dataclasses.is_dataclass() which returns true both for a dataclass type and for a dataclass instance.

So, there are two ways:

  1. Fix the documentation to match the current behavior. All uses of iselement() (see #135640) should also check if the argument is a type is they need an element object.
  2. Fix the implementation to check if the argument is a type. This may break the user code that uses it to check for the Element type (I don't know if it exists) but may fix bugs in the user code which expects that iselement() works as documented.

cc @scoder

Linked PRs
  • gh-136482
  • gh-136484

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

Empieza por la documentación y la implementación de ElementTree.iselement(); después, revisa los PR vinculados gh-136482 y gh-136484 y los usos referenciados en #135640. Se considera terminado cuando se haya resuelto si debe cambiar el comportamiento documentado o la implementación, y se haya actualizado de forma coherente el comportamiento o la documentación correspondiente.

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

Evaluación

Stack tecnológico
python
Área
api
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
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.