python / python/cpython

Unify interpretation of values of environment variables and CLI options

Aperta
#116,907 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

There is inconsistency in interpreting values of different environment variables that have equivalent of CLI options.

  • For some environment variables, defining them with any values (even empty) is interpreted as true.
  • For some environment variables, any values except 0 (including non-numbers and empty value) are interpreted as true. Only 0 is interpreted as false. For some of these variables it makes sense to set integer value > 1, but for other they are just booleans.
  • PYTHONUTF8 and PYTHON_GIL only accept "1" and "0". All other values are errors. Although the code for these two variables is very different.
  • PYTHON_FROZEN_MODULES only accepts "on" and "off". All other values are errors.
  • PYTHONCOERCECLOCALE has three state: "0", "warn" and... anything other.
  • Some environment variables has "0" as a special value, but PYTHON_CPU_COUNT uses "default".

There are similar things for corresponding CLI options which accept optional arguments.

Such diversity makes it difficult to document and use environment variables and CLI options. It can lead to subtle bugs if "0" is interpreted differently. An empty value of the environment variable can be the result of a hidden bug, but in most cases it is currently silently accepted and interpreted as true value.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia facendo un inventario delle variabili d’ambiente e delle opzioni CLI equivalenti descritte nell’issue, confrontando la loro gestione attuale dei valori vuoti, numerici, booleani e non validi. Prima dell’implementazione è necessario concordare una politica di interpretazione. Il lavoro sarà considerato completato quando le variabili d’ambiente elencate e le opzioni CLI corrispondenti seguiranno regole coerenti, inclusa una gestione coerente dei valori non validi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
cli
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.