python / python/cpython

Decide the fate of `enum.bin`

未关闭
#136,763 16 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@ethanfurman 已经在做这个了。

开始于 2025年7月18日。

docs stdlib
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。