Inconsistant behavior of .readable() and .writable() on io.IOBase
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- operating-systems
Direzione di ricerca
Inizia riproducendo i due esempi con file chiusi presenti nell’issue, quindi esamina i punti di ingresso io.IOBase.readable() e writable() e i relativi test. Il lavoro è completato quando i due metodi hanno un comportamento coerente e documentato per i file chiusi, preservando al contempo i risultati attesi per i file aperti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Merge medio
- 1g 9h
- PR unite (30g)
- 558
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python/cpython
-
docs pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
build type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
stdlib topic-email type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di python/cpython
Issue simili
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
bancolombia/sentinel#23 ·
-
test md ApertaCI
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100