Argument Clinic: move converters defined in several files to libclinic
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Several custom converters are defined in more than one C file:
pid_t— inposixmodule.c,_posixsubprocess.candresource.c.Py_off_t— inposixmodule.cand_ssl.c; thePy_off_ttype and the converter function are duplicated as well, and_iohas yet another copy of the type.HANDLE— in_multiprocessing/multiprocessing.c,overlapped.c,msvcrtmodule.c,_testconsole.cand_winapi.c.DWORD— inoverlapped.c,winreg.cand_winapi.c.BOOL— inoverlapped.cand_winapi.c.
The copies are not always equivalent: two of the pid_t converters compare the result with -1 instead of (pid_t)-1, and DWORD in _winapi.c uses the format unit "k", which accepts negative values, while in other modules it rejects them.
The registry of converters is global, so the definition in the file which is processed first can be used in other files. The generated code therefore depends on the order of processing — removing the definition of HANDLE from one module silently changes the code generated for others.
Other converters are defined only in posixmodule.c, although the corresponding C functions are already shared, so other modules convert the argument in the "impl" function instead of declaring its type:
uid_tandgid_t—_Py_Uid_Converter()and_Py_Gid_Converter()are declared inposixmodule.hand are called by hand inpwd.getpwuid(),grp.getgrgid()and_posixsubprocess.fork_exec().
There is no converter for time_t at all: time.gmtime(), time.localtime() and time.ctime() parse their argument with a hand-written helper, and _datetime calls _PyTime_ObjectToTime_t() directly.
I am going to move these converters to Tools/clinic/libclinic/converters.py.
Linked PRs
- gh-156262
- gh-156294
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
Inizia da Tools/clinic/libclinic/converters.py, quindi esamina le definizioni dei converter e le dichiarazioni condivise in posixmodule.c, _posixsubprocess.c, resource.c, _ssl.c, _io e nei moduli Windows elencati nella issue. Verifica come Argument Clinic elabora i moduli e confronta il codice generato; il lavoro è completato quando i converter sono centralizzati senza modificare i valori accettati o il comportamento generato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, python
- Ambito
- build-system, tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100