Inconsistant behavior of .readable() and .writable() on io.IOBase
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 558
Descripción
Bug report
The methods .readble() and .writable() on io.IOBase should return a boolean representing if the file can be read from/written to. However, calling .readable() on a closed IO file object causes a ValueError, whereas calling .writable() on a closed file returns False if the file was opened with just read permissions, but raises ValueError if it was opened with read and write permissions.
Make a folder with a text file in, then run:
f = open("hello.txt")
print(f.writable())
print(f.readable())
f.close()
print(f.writable())
print(f.readable())
This will output:
False
True
False
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
Then doing a similar thing, but with w+ permissions
f = open("hello.txt", "w+")
print(f.writable())
print(f.readable())
f.close()
print(f.writable())
print(f.readable())
Will output
True
True
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
Your environment
- CPython versions tested on: 3.10.4
- Operating system and architecture: Windows 64bit
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.
Línea de trabajo
Comienza reproduciendo los dos ejemplos con archivos cerrados del issue y, a continuación, inspecciona los puntos de entrada io.IOBase.readable() y writable(), junto con sus pruebas relacionadas. Se considera terminado cuando los dos métodos tienen un comportamiento coherente y documentado para archivos cerrados, preservando al mismo tiempo los resultados esperados para archivos abiertos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- operating-systems
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100