python / python/cpython

Decide the fate of `enum.bin`

Aperta
#136,763 16 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@ethanfurman ci sta già lavorando.

Dal 18/7/2025.

docs stdlib
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

First, this module defines a bin function that is not present in the documentation. Such a method should be documented or made private. Indeed, it would feel weird for a user to use from enum import * and have the standard bin() function overriden.

The commit that introcuced this function is #https://github.com/python/cpython/commit/7aaeb2a3d682ecba125c33511e4b4796021d2f82
This function only appears to have be used by the commit for Flag.missing, where it's present two or three times

Thus, i guess this function was created for internal code refactorisation.
This is a normal use for a function. However, a function used for this should not be available to an importer of enum. It should especially not be able to cause problems in the code of the importer.

I suggest renaming the function _bin and replacing existing occurences of call to this function by a call to its new name.

Broadlier speaking, I do not see a valid reason for the import of builtins in the enum module, because it is bad practice: the only use case is builtin functions having been redefined inside the code, which is a source of confusions and errors and therefore not good practice.

This probably means they're other problems like this in the enum module. One I found is the decorator @property. I did not investigated this one further.

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.