OSError stubs don't match actual types for TimeoutError subclass
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 5.1k
- Fork
- 2.1k
- Merge medio
- 1g 19h
- PR unite (30g)
- 82
Descrizione
OSError is currently stubbed as:
class OSError(Exception):
errno: int
strerror: str
# filename, filename2 are actually str | bytes | None
filename: Any
filename2: Any
if sys.platform == "win32":
winerror: int
The CPython TimeoutError subclass of it returned by socket functions will sometimes have errno and strerror None depending on which underlying syscall detected the timeout (select() reporting 0 sockets ready vs something failing with ETIMEDOUT)
Example:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.1)
try:
# Try to connect to a host that doesn't exist on your
# network
s.connect(("10.10.10.10", 22))
except OSError as ex:
print(repr(ex))
print(f"errno is {type(ex.errno)} - {ex.errno}")
print(f"strerror is {type(ex.strerror)} - {ex.strerror}")
produces
TimeoutError('timed out')
errno is <class 'NoneType'> - None
strerror is <class 'NoneType'> - None
on
Python 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:14:58) [MSC v.1929 64 bit (AMD64)]
The CPython implementation looks like it would do the same on all platforms
(@srittau 2024-09-02) Deferred until python/cpython#109601 and python/cpython#109714 are decided on.
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.
Direzione di ricerca
Esamina la dichiarazione di OSError e riproduci l’esempio di timeout del socket per confermare i valori a runtime di errno e strerror. Esamina prima python/cpython#109601 e python/cpython#109714; il lavoro è completato quando lo stub corrisponde al comportamento CPython stabilito, inclusi eventuali valori None.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100