Python 3.13 property() 现在从 callable 继承 __name__

问题描述 投票:0回答:1

在尝试使用 Python 3.13b2 构建 Pyramid 时,我发现一些测试失败了。 问题似乎是 Python 行为的变化。

使用 Python 3.12 我得到:

>>> def worker(obj):
...     pass
...
>>> hasattr(property(worker), '__name__')
False

Python 3.13 回归时:

>>> def worker(obj):
...     pass
...
>>> hasattr(property(worker), '__name__')
True
>>> property(worker).__name__
'worker'

我已向 Pyramid 提交了一份 bug 报告,但我不确定正确的行为是 3.12 中的行为还是 3.13 中的行为。我应该针对 Python 提交错误吗?

python pyramid
1个回答
0
投票

这是一个有意的更改,可以在 Python 3.13.0 alpha 5 下的 changelog 中看到:

  • gh-101860:公开属性上的
    __name__
    属性。
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.