csv.Dialect: Defaults are documented but not correctly implemented
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Empieza por los puntos de entrada de csv.py para csv.Dialect y csv.excel; después, ejecuta el reproducer del issue para observar los valores predeterminados actuales y el error. Se considerará terminado cuando los valores predeterminados documentados de Dialect se comporten como se describe sin romper el comportamiento existente de csv; gh-100336 ya está vinculado como trabajo relacionado con este issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug report
In gh-68335, it was reported that the default values for csv.Dialect were not documented properly. They are, as pointed out by @smontanaro there, at https://docs.python.org/2/library/csv.html#dialects-and-formatting-parameters -- and still are for Python 3.11.
However, while I was attempting to fix gh-73138, I discovered that all arguments of csv.Dialect are None and even trigger unexpected behavior (if following the documentation):
import csv
class mydialect(csv.Dialect):
quotechar = ":"
mydialect()
raises a _csv.Error caused by a TypeError, instead of using the documented default delimiter ,.
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/csv.py", line 49, in _validate
_Dialect(self)
TypeError: "delimiter" must be string, not NoneType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/csv.py", line 45, in __init__
self._validate()
File "/opt/homebrew/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/csv.py", line 52, in _validate
raise Error(str(e))
_csv.Error: "delimiter" must be string, not NoneType
The discrepancy is, that the documented default values are not for the csv.Dialect class, but for its child csv.excel.
In gh-96842, a fix was prepared, improving the documentation to point this out.
I think a better fix would be to actually add the proper default values as they are written in the documentation.
The updated documentation in gh-96842 might be easily missed, and developers implementing a csv.Dialect would expect the defaults to be as documented, not as the csv.excel has them (if they want to inherit from csv.excel, they can still do so explicitly).
Your environment
- CPython versions tested on: Python 3.10, 3.11, and from the main branch `Python 3.12.0a3+
- Operating system and architecture: MacOS arm
Linked PRs
- gh-100336
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 558
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 python/cpython
-
docs pending
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
build type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
stdlib topic-email type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Todos los issues de python/cpython
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
🐛 Bug 🔔 Pending processing
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
jumpserver/jumpserver#17584 ·