Python Enhancement Proposals

PEP 4 – Deprecation of Standard Modules

PEP
4
Title
标准模块的废弃情况
Author
Brett Cannon <brett at python.org>, Martin von Löwis <martin at v.loewis.de>
Status
Active
Type
Process
Created
01-Oct-2000
Post-History


Contents

介绍

过去当新的模块被添加到标准的 Python 库中时,不可能预见到它们在未来是否仍然有用。即使 Python “附带电池”,电池也会随着时间的推移而放电。携带旧模块是维护者的负担,特别是当人们对模块不再感兴趣的时候。

同时,从发行版中移除一个模块是很困难的,因为一般来说,不知道是否还有人在使用它。这个 PEP 定义了一个从标准 Python 库中移除模块的程序。一个模块的使用可能会被 “废弃”(’deprecated’),这意味着它可能会被从未来的 Python 版本中移除。废弃一个模块的理由也被收集在这个 PEP 中。如果理由被证明是错误的,那么该模块可能会成为 “非废弃”(’undeprecated’)。

宣布一个模块被废弃的程序

由于本 PEP 中记录了模块废弃的状态,因此关于废弃模块的提议必须通过对本 PEP 的文本进行修改来提出。

废除模块的提议必须包括提议废除的日期和废除的理由。此外,提议必须包括对模块文档的修改;废弃的表示方法是:该模块是 “obsolete” 或 “deprecated”。提案应该包括对模块源代码的补丁,通过引发 DeprecationWarning 来表明该模块的废弃。该提案必须包括补丁,以从标准库中移除对废弃模块的任何使用。

我们希望被废弃的模块包含在紧随废弃的 Python 版本中;以后的版本可能没有废弃的模块。

对于同时存在于 Python 2.7 和 Python 3.5 中的模块来说

为了方便编写可以同时在 Python 2 和 3 中工作的代码,任何同时存在于 Python 3.5 和 Python 2.7 中的模块将不会从标准库中移除,直到 PEP 373 规定的 Python 2.7 不再被支持。这一规则的例外是 idlelib 包中的任何模块,以及 Python 开发团队授予的任何例外。

宣布模块为非废弃模块的程序

当一个模块被废弃时,会给出其废弃的理由。在某些情况下,提供了相同功能的替代接口,所以旧的接口被废弃了。在其他情况下,拥有该模块功能的需求可能不再存在。

如果理由是错误的,必须再次提交对该PEP文本的修改。这个修改必须包括取消使用的日期和取消使用的理由。在这个过程中被取消的模块必须被列在这个 PEP 中,至少在 Python 的一个主要版本中。

过时的模块

一些模块已经在库文件中被列为过时的模块。为了完整起见,我们在此列出这些模块。

cl, sv, timing

所有这些模块在 Python 2.0 中都被宣布为过时,有些甚至更早。

在 Python 2.5 中移除了下列过时的模块:

addpack, cmp, cmpcache, codehack, dircmp, dump, find, fmt, grep, lockfile, newdir, ni, packmail, Para, poly, rand, reconvert, regex, regsub, statcache, tb, tzparse, util, whatsound, whrandom, zmod

以下模块在 Python 2.6 中被移除:

gopherlib, rgbimg, macfs

以下模块目前缺乏 DeprecationWarning:

rfc822, mimetools, multifile

废弃的模块

Module name:   posixfile
Rationale:     Locking is better done by fcntl.lockf().
Date:          Before 1-Oct-2000.
Documentation: Already documented as obsolete.  Deprecation
               warning added in Python 2.6.

Module name:   gopherlib
Rationale:     The gopher protocol is not in active use anymore.
Date:          1-Oct-2000.
Documentation: Documented as deprecated since Python 2.5.  Removed
               in Python 2.6.

Module name:   rgbimgmodule
Rationale:     In a 2001-04-24 c.l.py post, Jason Petrone mentions
               that he occasionally uses it; no other references to
               its use can be found as of 2003-11-19.
Date:          1-Oct-2000
Documentation: Documented as deprecated since Python 2.5.  Removed
               in Python 2.6.

Module name:   pre
Rationale:     The underlying PCRE engine doesn't support Unicode, and
               has been unmaintained since Python 1.5.2.
Date:          10-Apr-2002
Documentation: It was only mentioned as an implementation detail,
               and never had a section of its own.   This mention
               has now been removed.

Module name:   whrandom
Rationale:     The module's default seed computation was
               inherently insecure; the random module should be
               used instead.
Date:          11-Apr-2002
Documentation: This module has been documented as obsolete since
               Python 2.1, but listing in this PEP was neglected.
               The deprecation warning will be added to the module
               one year after Python 2.3 is released, and the
               module will be removed one year after that.

Module name:   rfc822
Rationale:     Supplanted by Python 2.2's email package.
Date:          18-Mar-2002
Documentation: Documented as "deprecated since release 2.3" since
               Python 2.2.2.

Module name:   mimetools
Rationale:     Supplanted by Python 2.2's email package.
Date:          18-Mar-2002
Documentation: Documented as "deprecated since release 2.3" since
               Python 2.2.2.

Module name:   MimeWriter
Rationale:     Supplanted by Python 2.2's email package.
Date:          18-Mar-2002
Documentation: Documented as "deprecated since release 2.3" since
               Python 2.2.2.  Raises a DeprecationWarning as of
               Python 2.6.

Module name:   mimify
Rationale:     Supplanted by Python 2.2's email package.
Date:          18-Mar-2002
Documentation: Documented as "deprecated since release 2.3" since
               Python 2.2.2.  Raises a DeprecationWarning as of
               Python 2.6.

Module name:   rotor
Rationale:     Uses insecure algorithm.
Date:          24-Apr-2003
Documentation: The documentation has been removed from the library
               reference in Python 2.4.

Module name:   TERMIOS.py
Rationale:     The constants in this file are now in the 'termios' module.
Date:          10-Aug-2004
Documentation: This module has been documented as obsolete since
               Python 2.1, but listing in this PEP was neglected.
               Removed from the library reference in Python 2.4.

Module name:   statcache
Rationale:     Using the cache can be fragile and error-prone;
               applications should just use os.stat() directly.
Date:          10-Aug-2004
Documentation: This module has been documented as obsolete since
               Python 2.2, but listing in this PEP was neglected.
               Removed from the library reference in Python 2.5.

Module name:   mpz
Rationale:     Third-party packages provide similar features
               and wrap more of GMP's API.
Date:          10-Aug-2004
Documentation: This module has been documented as obsolete since
               Python 2.2, but listing in this PEP was neglected.
               Removed from the library reference in Python 2.4.

Module name:   xreadlines
Rationale:     Using 'for line in file', introduced in 2.3, is preferable.
Date:          10-Aug-2004
Documentation: This module has been documented as obsolete since
               Python 2.3, but listing in this PEP was neglected.
               Removed from the library reference in Python 2.4.

Module name:   multifile
Rationale:     Supplanted by the email package.
Date:          21-Feb-2006
Documentation: Documented as deprecated as of Python 2.5.

Module name:   sets
Rationale:     The built-in set/frozenset types, introduced in
               Python 2.4, supplant the module.
Date:          12-Jan-2007
Documentation: Documented as deprecated as of Python 2.6.

Module name:   buildtools
Rationale:     Unknown.
Date:          15-May-2007
Documentation: Documented as deprecated as of Python 2.3, but
               listing in this PEP was neglected.  Raised a
               DeprecationWarning as of Python 2.6.

Module name:   cfmfile
Rationale:     Unknown.
Date:          15-May-2007
Documentation: Documented as deprecated as of Python 2.4, but
               listing in this PEP was neglected.  A
               DeprecationWarning was added in Python 2.6.

Module name:   macfs
Rationale:     Unknown.
Date:          15-May-2007
Documentation: Documented as deprecated as of Python 2.3, but
               listing in this PEP was neglected.  Removed in
               Python 2.6.

Module name:   md5
Rationale:     Replaced by the 'hashlib' module.
Date:          15-May-2007
Documentation: Documented as deprecated as of Python 2.5, but
               listing in this PEP was neglected.
               DeprecationWarning raised as of Python 2.6.

Module name:   sha
Rationale:     Replaced by the 'hashlib' module.
Date:          15-May-2007
Documentation: Documented as deprecated as of Python 2.5, but
               listing in this PEP was neglected.
               DeprecationWarning added in Python 2.6.

Module name:   plat-freebsd2/IN and plat-freebsd3/IN
Rationale:     Platforms are obsolete (last released in 2000)
               Removed from 2.6
Date:          15-May-2007
Documentation: None

Module name:   plat-freebsd4/IN and possibly plat-freebsd5/IN
Rationale:     Platforms are obsolete/unsupported
Date:          15-May-2007
               Remove from 2.7
Documentation: None

Module name:   imp
Rationale:     Replaced by the importlib module.
Date:          2013-02-10
Documentation: Deprecated as of Python 3.4.

Module name:   formatter
Rationale:     Lack of use in the community, no tests to keep
               code working.
Date:          2013-08-12
Documentation: Deprecated as of Python 3.4.

Module name:   macpath
Rationale:     Obsolete macpath module dangerously broken
               and should be removed.
Date:          2017-05-15
Documentation: Platform is obsolete/unsupported.

Module name:   xml.etree.cElementTree
Rationale:     Obsolete, use xml.etree.ElementTree
Date:          2019-04-06
Documentation: Documented as deprecated since 3.3

在 Python 3.0 中移除的模块的废弃情况

PEP 3108 列出了所有已经从 Python 3.0 中移除的模块。它们都被记录为在 Python 2.6 中被废弃,如果激活了 -3 标志,就会引发 DeprecationWarning。

未废弃的模块

None.

Source: https://github.com/python/peps/blob/master/pep-0004.txt

Last modified: 2021-02-09 16:54:26 GMT