为什么他们在旧的 Python 3 版本上有一些新版本的 Python 3?

Why are they some new releases of Python 3 on older Python 3 versions?

现在,在 Python Software Foundation 网站的 "All releases" 页面上,"Download latest release" 链接到 Python 3.6.4 版本。 但是,您可以在页面上找到版本来自 2017-12-19 的版本,此后还有另外两个版本,Python 3.5.5 和 Python 3.4.8 .

我明白为什么 Python 有 3 和 2.7 的两个并行版本,但我不明白为什么它们是 Python 3 的多个版本,因为它应该向后兼容 Python 3代码。

Python 3.x 不一定向后兼容。例如在 python 3.6 中,引入了字符串插值,又名 f-string。 在 python 3.5 中引入了类型提示,它不会向后兼容旧的 3.x 版本。

x.y.Z 点版本通常是 错误修复版本.
x.Y 版本通常是功能版本,但可能包含 次要 向后不兼容。
X 版本是很大的变化,可能会破坏很多现有代码。

实际上,您不能总是立即升级 x.Y 版本;原因包括无法快速修复的实际代码不兼容性、内部部署限制和调度原因。 Linux 发行版也经常分发一个特定的 x.Y 版本,并且只会在一年左右的年度发布周期中选择下一个版本。但是,x.y.Z 版本通常很快就会被获取,并且通常可以在不破坏现有代码的情况下安装。

几个 x.y.Z 版本并行维护的原因是用户希望获得错误修复的好处,而不必被迫升级到新的主要版本。

Python Development Cycle 页面描述了 python 如何维护版本。以下是一些片段:

17.1.1. In-development (main) branch

The master branch is the branch for the next feature release; it is under active development for all kinds of changes: new features, semantic changes, performance improvements, bug fixes.

17.1.2. Maintenance branches

A branch for a previous feature release, currently being maintained for bug fixes. There are usually two maintenance branches at any given time: one for Python 3.x and one for Python 2.x.

17.1.3. Security branches

A branch less than 5 years old but no longer in maintenance mode is a security branch. The only changes made to a security branch are those fixing issues exploitable by attackers such as crashes, privilege escalation and, optionally, other issues such as denial of service attacks.

因此,除了接收新功能更新的主分支外,还有一个维护分支接收 Python 2 和 3 的一般错误修复,以及许多其他分支接收安全修复。当应用 bug/security 修复程序时,micro/patch 版本(版本中的第三个数字)会增加。这是写这篇文章时的快照,来自同一文档:

17.1.4. Summary

There are 6 open branches right now in the Git repository:

  • the master branch accepts features and bugs fixes for the future 3.8.0 feature release (RM: Łukasz Langa)
  • the 3.7 branch accepts bug, regression, and doc fixes for the upcoming 3.7.0 feature release (RM: Ned Deily)
  • the 3.6 branch accepts bug fixes for future 3.6.x maintenance releases (RM: Ned Deily)
  • the 3.5 branch accepts security fixes for future 3.5.x security releases (RM: Larry Hastings)
  • the 3.4 branch accepts security fixes for future 3.4.x security releases (RM: Larry Hastings)
  • the 2.7 branch accepts bug fixes for future 2.7.x maintenance releases (RM: Benjamin Peterson)