This PEP proposed a list of standard library modules to be removed from the standard library. The modules are mostly historic data formats and APIs that have been superseded a long time ago, e.g. Mac OS 9 and Commodore.

Back in the early days of Python, the interpreter came with a large set of useful modules. This was often refrained to as "batteries included" philosophy and was one of the corner stones to Python's success story. Users didn't have to figure out how to download and install separate packages in order to write a simple web server or parse email.

Times have changed. The introduction of the cheese shop (PyPI), setuptools, and later pip, it became simple and straight forward to download and install packages. Nowadays Python has a rich and vibrant ecosystem of third party packages. It's pretty much standard to either install packages from PyPI or use one of the many Python or Linux distributions.

On the other hand, Python's standard library is piling up cruft, unnecessary duplication of functionality, and dispensable features. This is undesirable for several reasons.

  • Any additional module increases the maintenance cost for the Python core development team. The team has limited resources, reduced maintenance cost frees development time for other improvements.
  • Modules in the standard library are generally favored and seen as the de-facto solution for a problem. A majority of users only pick 3rd party modules to replace a stdlib module, when they have a compelling reason, e.g. lxml instead of xml. The removal of an unmaintained stdlib module increases the chances of a community contributed module to become widely used.
  • A lean and mean standard library benefits platforms with limited resources like devices with just a few hundred kilobyte of storage (e.g. BBC Micro:bit). Python on mobile platforms like BeeWare or WebAssembly (e.g. pyodide) also benefit from reduced download size.

The modules in the PEP have been selected for deprecation because their removal is either least controversial or most beneficial. For example least controversial are 30 years old multimedia formats like sunau audio format, which was used on SPARC and NeXT workstations in the late 1980ties. The crypt module has fundamental flaws that are better solved outside the standard library.

This PEP also designates some modules as not scheduled for removal. Some modules have been deprecated for several releases or seem unnecessary at first glance. However it is beneficial to keep the modules in the standard library, mostly for environments where installing a package from PyPI is not an option. This can be cooperate environments or class rooms where external code is not permitted without legal approval.

  • The usage of FTP is declining, but some files are still provided over the FTP protocol or hosters offer FTP to upload content. Therefore ftplib is going to stay.
  • The optparse and getopt module are widely used. They are mature modules with very low maintenance overhead.
  • According to David Beazley [5] the wave module is easy to teach to kids and can make crazy sounds. Making a computer generate crazy sounds is powerful and highly motivating exercise for a 9yo aspiring developer. It's a fun battery to keep.

This PEP targets Python 3.8. Version 3.8.0 final is scheduled to be released a few months before Python 2.7 will reach its end of lifetime. We expect that Python 3.8 will be targeted by users that migrate to Python 3 in 2019 and 2020. To reduce churn and to allow a smooth transition from Python 2, Python 3.8 will neither raise DeprecationWarning nor remove any modules that have been scheduled for removal. Instead deprecated modules will just be documented as deprecated. Optionally modules may emit a PendingDeprecationWarning.

All deprecated modules will also undergo a feature freeze. No additional features should be added. Bug should still be fixed.

Starting with Python 3.9, deprecated modules will start issuing DeprecationWarning. The parser [19] module is removed and potentially replaced with a new module.

All other deprecated modules are fully supported and will receive security updates until Python 3.9 reaches its end of lifetime. Python 3.9.0 will be released about 18 months after 3.8.0 (April 2021?) and most likely be supported for 5 years after the release. The estimated EOL of Python 3.9 is in 2026.

In 3.10 all deprecated modules will be removed from the CPython repository together with tests, documentation, and autoconf rules.

3.8.0b1 is scheduled to be release shortly after the PEP is officially submitted. Since it's improbable that the PEP will pass all stages of the PEP process in time, I propose a two step acceptance process that is analogous Python's two release deprecation process.

The first provisionally accepted phase targets Python 3.8.0b1. In the first phase no code is changes or removed. Modules are only documented as deprecated. The only exception is the parser [19] module. It has been documented as deprecated since Python 2.5 and is scheduled for removal for 3.9 to make place for a more advanced parser.

The final decision, which modules will be removed and how the removed code is preserved, can be delayed for another year.

The modules are grouped as data encoding, multimedia, network, OS interface, and misc modules. The majority of modules are for old data formats or old APIs. Some others are rarely useful and have better replacements on PyPI, e.g. Pillow for image processing or NumPy-based projects to deal with audio processing.

Table 1: Proposed modules deprecations
Module Deprecated in To be removed Has expert? Replacement
aifc 3.8 3.10 yes (inactive) -
asynchat 3.6 3.10 yes asyncio
asyncore 3.6 3.10 yes asyncio
audioop 3.8 3.10 yes -
binhex 3.8 3.10 no -
cgi 3.8 3.10 no -
cgitb 3.8 3.10 no -
chunk 3.8 3.10 no -
crypt 3.8 3.10 yes (inactive) bcrypt, argon2cffi, hashlib, passlib
formatter 3.4 3.10 no -
fpectl 3.7 3.7 n/a -
imghdr 3.8 3.10 no filetype, puremagic, python-magic
imp 3.4 3.10 yes importlib
macpath 3.7 3.8 n/a -
msilib 3.8 3.10 no -
nntplib 3.8 3.10 no -
nis 3.8 3.10 no -
ossaudiodev 3.8 3.10 no -
parser 2.5 3.9 yes ast, lib2to3.pgen2
pipes 3.8 3.10 no subprocess
smtpd 3.4.7, 3.5.4 3.10 yes aiosmtpd
sndhdr 3.8 3.10 no filetype, puremagic, python-magic
spwd 3.8 3.10 no python-pam, simplepam
sunau 3.8 3.10 no -
uu 3.8 3.10 no -
xdrlib 3.8 3.10 no -

The binhex module encodes and decodes Apple Macintosh binhex4 data. It was originally developed for TSR-80. In the 1980s and early 1990s it was used on classic Mac OS 9 to encode binary email attachments.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The uu module provides uuencode format, an old binary encoding format for email from 1980. The uu format has been replaced by MIME. The uu codec is provided by the binascii module.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The xdrlib module supports the Sun External Data Representation Standard. XDR is an old binary serialization format from 1987. These days it's rarely used outside specialized domains like NFS.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The aifc module provides support for reading and writing AIFF and AIFF-C files. The Audio Interchange File Format is an old audio format from 1988 based on Amiga IFF. It was most commonly used on the Apple Macintosh. These days only few specialized application use AIFF.

Module type
pure Python (depends on audioop [9] C extension)
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
yes, but expert is currently inactive.
Substitute
none

The audioop module contains helper functions to manipulate raw audio data and adaptive differential pulse-code modulated audio data. The module is implemented in C without any additional dependencies. The aifc [8], sunau [12], and wave [22] module depend on audioop [9] for some operations. The byteswap operation in the wave [22] module can be substituted with little work.

Module type
C extension
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
yes
Substitute
none

The chunk module provides support for reading and writing Electronic Arts' Interchange File Format. IFF is an old audio file format originally introduced for Commodore and Amiga. The format is no longer relevant.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The imghdr module is a simple tool to guess the image file format from the first 32 bytes of a file or buffer. It supports only a limited amount of formats and neither returns resolution nor color depth.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
puremagic, filetype, python-magic

The ossaudiodev module provides support for Open Sound System, an interface to sound playback and capture devices. OSS was initially free software, but later support for newer sound devices and improvements were proprietary. Linux community abandoned OSS in favor of ALSA [1]. Some operation systems like OpenBSD and NetBSD provide an incomplete [2] emulation of OSS.

Module type
C extension
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The sndhdr module is similar to the imghdr [10] module but for audio formats. It guesses file format, channels, frame rate, and sample widths from the first 512 bytes of a file or buffer. The module only supports AU, AIFF, HCOM, VOC, WAV, and other ancient formats.

Module type
pure Python (depends on audioop [9] C extension for some operations)
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
puremagic, filetype, python-magic

The sunau module provides support for Sun AU sound format. It's yet another old, obsolete file format.

Module type
pure Python (depends on audioop [9] C extension for some operations)
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The asynchat module is build on top of asyncore [13] and has been deprecated since Python 3.6.

Module type
pure Python
Deprecated in
3.6
Removed in
3.10
Has a designated expert
yes
Substitute
asyncio

The asyncore module was the first module for asynchronous socket service clients and servers. It has been replaced by asyncio and is deprecated since Python 3.6.

The asyncore module is also used in stdlib tests. The tests for ftplib, logging, smptd, smtplib, and ssl are partly based on asyncore. These tests must be updated to use asyncio or threading.

Module type
pure Python
Deprecated in
3.6
Removed in
3.10
Has a designated expert
yes
Substitute
asyncio

The cgi module is a support module for Common Gateway Interface (CGI) scripts. CGI is deemed as inefficient because every incoming request is handled in a new process. PEP 206 considers the module as designed poorly and are now near-impossible to fix.

Several people proposed to either keep the cgi module for features like cgi.parse_qs() or move cgi.escape() to a different module. The functions cgi.parse_qs and cgi.parse_qsl have been deprecated for a while and are actually aliases for urllib.parse.parse_qs and urllib.parse.parse_qsl. The function cgi.quote has been deprecated in favor of html.quote with secure default values.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The cgitb module is a helper for the cgi module for configurable tracebacks.

The cgitb module is not used by any major Python web framework (Django, Pyramid, Plone, Flask, CherryPy, or Bottle). Only Paste uses it in an optional debugging middleware.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The smtpd module provides a simple implementation of a SMTP mail server. The module documentation marks the module as deprecated and recommends aiosmtpd instead. The deprecation message was added in releases 3.4.7, 3.5.4, and 3.6.1.

Module type
pure Python
Deprecated in
3.4.7, 3.5.4, 3.6.1
To be removed in
3.10
Has a designated expert
yes
Substitute
aiosmtpd

The nntplib module implements the client side of the Network News Transfer Protocol (nntp). News groups used to be a dominant platform for online discussions. Over the last two decades, news has been slowly but steadily replaced with mailing lists and web-based discussion platforms. Twisted is also planning to deprecate NNTP support and pynnt hasn't seen any activity since 2014. This is a good indicator that the public interest in NNTP support is declining.

The nntplib tests have been the cause of additional work in the recent past. Python only contains client side of NNTP. The tests connect to external news server. The servers are sometimes unavailble, too slow, or do not work correctly over IPv6. The situation causes flaky test runs on buildbots.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The crypt module implements password hashing based on crypt(3) function from libcrypt or libxcrypt on Unix-like platform. The algorithms are mostly old, of poor quality and insecure. Users are discouraged to use them.

  • The module is not available on Windows. Cross-platform application need an alternative implementation any way.
  • Only DES encryption is guarenteed to be available. DES has an extremely limited key space of 2**56.
  • MD5, salted SHA256, salted SHA512, and Blowfish are optional extension. SSHA256 and SSHA512 are glibc extensions. Blowfish (bcrypt) is the only algorithm that is still secure. However it's in glibc and therefore not commonly available on Linux.
  • Depending on the platform, the crypt module is not thread safe. Only implementations with crypt_r(3) are thread safe.
  • The module was never useful to interact with system user and password databases. On BSD, macOS, and Linux, all user authentication and password modification operations must go through PAM (pluggable authentication module), see spwd [18] deprecation.
Module type
C extension + Python module
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
yes, but expert is currently inactive.
Substitute
bcrypt, passlib, argon2cffi, hashlib module (PBKDF2, scrypt)

The macpath module provides Mac OS 9 implementation of os.path routines. Mac OS 9 is no longer supported

Module type
pure Python
Deprecated in
3.7
Removed in
3.8
Has a designated expert
n/a
Substitute
none

The nis module provides NIS/YP support. Network Information Service / Yellow Pages is an old and deprecated directory service protocol developed by Sun Microsystems. It's designed successor NIS+ from 1992 never took off. For a long time, libc's Name Service Switch, LDAP, and Kerberos/GSSAPI are considered a more powerful and more secure replacement of NIS.

Module type
C extension
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The spwd module provides direct access to Unix shadow password database using non-standard APIs.

In general it's a bad idea to use the spwd. The spwd circumvents system security policies, it does not use the PAM stack, and is only compatible with local user accounts, because it ignores NSS. The use of the spwd module for access control must be consider a security bug, as it bypasses PAM's access control.

Further more the spwd module uses the shadow(3) APIs. Functions like getspnam(3) access the /etc/shadow file directly. This is dangerous and even forbidden for confined services on systems with a security engine like SELinux or AppArmor.

Module type
C extension
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
python-pam, simpleplam

The formatter module is an old text formatting module which has been deprecated since Python 3.4.

Module type
pure Python
Deprecated in
3.4
To be removed in
3.10
Has a designated expert
no
Substitute
n/a

The imp module is the predecessor of the importlib module. Most functions have been deprecated since Python 3.3 and the module since Python 3.4.

Module type
C extension
Deprecated in
3.4
To be removed in
3.10
Has a designated expert
yes, experts have deprecated the module
Substitute
importlib

The msilib package is a Windows-only package. It supports the creation of Microsoft Installers (MSI). The package also exposes additional APIs to create cabinet files (CAB). The module is used to facilitate distutils to create MSI installers with bdist_msi command. In the past it was used to create CPython's official Windows installer, too.

Microsoft is slowly moving away from MSI in favor of Windows 10 Apps (AppX) as new deployment model [3].

Module type
C extension + Python code
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
none

The parser module provides an interface to Python’s internal parser and byte-code compiler. The stdlib has superior ways to interact with the parse tree. From Python 2.5 onward, it's much more convenient to cut in at the Abstract Syntax Tree (AST) generation and compilation stage.

The parser module causes additional work. It's C code that must be kept in sync with any change to Python's grammar and internal parser. Pablo wants to remove the parser module and promote lib2to3's pgen2 instead [6].

Most importantly the presence of the parser module makes it harder to switch to something more powerful than a LL(1) parser [7]. Since the parser module is documented as deprecated since Python 2.5 and a new parsing technology is planned for 3.9, the parser module is scheduled for removal in 3.9.

Module type
C extension
Deprecated in
3.8, documented as deprecated since 2.5
To be removed in
3.9
Has a designated expert
yes, experts have deprecated the module.
Substitute
ast, lib2to3.pgen2

The pipes module provides helpers to pipe the input of one command into the output of another command. The module is built on top of os.popen. Users are encouraged to use the subprocess module instead.

Module type
pure Python
Deprecated in
3.8
To be removed in
3.10
Has a designated expert
no
Substitute
subprocess module

The fpectl module was never built by default, its usage was discouraged and considered dangerous. It also required a configure flag that caused an ABI incompatibility. The module was removed in 3.7 by Nathaniel J. Smith in bpo-29137.

Module type
C extension + CAPI
Deprecated in
3.7
Removed in
3.7
Has a designated expert
n/a
Substitute
none

Some modules were originally proposed for deprecation.

Table 2: Withdrawn deprecations
Module Deprecated in Replacement
colorsys - colormath, colour, colorspacious, Pillow
fileinput - argparse
getopt - argparse, optparse
lib2to3 -  
optparse 3.2 argparse
wave -  

The colorsys module defines color conversion functions between RGB, YIQ, HSL, and HSV coordinate systems.

Walter Dörwald, Petr Viktorin, and others requested to keep colorsys. The module is useful to convert CSS colors between coordinate systems. The implementation is simple, mature, and does not impose maintenance overhead on core development.

The PyPI packages colormath, colour, and colorspacious provide more and advanced features. The Pillow library is better suited to transform images between color systems.

Module type
pure Python
Has a designated expert
no
Substitute
colormath, colour colorspacious, Pillow

The fileinput module implements a helpers to iterate over a list of files from sys.argv. The module predates the optparser and argparser module. The same functionality can be implemented with the argparser module.

Several core developers expressed their interest to keep the module in the standard library, as it is handy for quick scripts.

Module type
pure Python
Has a designated expert
no

The lib2to3 package provides the 2to3 command to transpile Python 2 code to Python 3 code.

The package is useful for other tasks besides porting code from Python 2 to 3. For example black [23] uses it for code reformatting.

Module type
pure Python
Has a designated expert
no

The getopt module mimics C's getopt() option parser.

Although users are encouraged to use argparse instead, the getopt module is still widely used. The module is small, simple, and handy for C developers to write simple Python scripts.

Module type
pure Python
Has a designated expert
no
Substitute
argparse

The optparse module is the predecessor of the argparse module.

Although it has been deprecated for many years, it's still too widely used to remove it.

Module type
pure Python
Deprecated in
3.2
Has a designated expert
yes
Substitute
argparse

The wave module provides support for the WAV sound format.

The module is not deprecated, because The WAV format is still relevant these days. The wave module is also used in education, e.g. to show kids how to make noise with a computer.

The module uses one simple function from the audioop [9] module to perform byte swapping between little and big endian formats. Before 24 bit WAV support was added, byte swap used to be implemented with the array module. To remove wave's dependency on the audioop, the byte swap function could be either be moved to another module (e.g. operator) or the array module could gain support for 24 bit (3 byte) arrays.

Module type
pure Python (depends on byteswap from audioop [9] C extension)
Has a designated expert
no

The main goal of the PEP is to reduce the burden and workload on the Python core developer team. Therefore removed modules will not be maintained by the core team as separate PyPI packages. However the removed code, tests and documentation may be moved into a new git repository, so community members have a place from which they can pick up and fork code.

A first draft of a legacylib repository is available on my private Github account. The modules could be made available on PyPI. The Python core team will not publish or maintain the packages. It is my hope that members of the Python community will adopt, maintain, and perhaps improve the deprecated modules.

It's my hope that some of the deprecated modules will be picked up and adopted by users that actually care about them. For example colorsys and imghdr are useful modules, but have limited feature set. A fork of imghdr can add new features and support for more image formats, without being constrained by Python's release cycle.

Most of the modules are in pure Python and can be easily packaged. Some depend on a simple C module, e.g. audioop [9] and crypt [17]. Since audioop [9] does not depend on any external libraries, it can be shipped in as binary wheels with some effort. Other C modules can be replaced with ctypes or cffi. For example I created legacycrypt with _crypt extension reimplemented with a few lines of ctypes code.

  • Elana Hashman and Nick Coghlan suggested to keep the getopt module.
  • Berker Peksag proposed to deprecate and removed msilib.
  • Brett Cannon recommended to delay active deprecation warnings and removal of modules like imp until Python 3.10. Version 3.8 will be released shortly before Python 2 reaches end of lifetime. A delay reduced churn for users that migrate from Python 2 to 3.8.
  • Brett also came up with the idea to keep lib2to3. The package is useful for other purposes, e.g. black uses it to reformat Python code.
  • At one point, distutils was mentioned in the same sentence as this PEP. To avoid lengthy discussion and delay of the PEP, I decided against dealing with distutils. Deprecation of the distutils package will be handled by another PEP.
  • Multiple people (Gregory P. Smith, David Beazley, Nick Coghlan, ...) convinced me to keep the wave [22] module. [4]
  • Gregory P. Smith proposed to deprecate nntplib [16]. [4]
  • Andrew Svetlov mentioned the socketserver module is questionable. However it's used to implement http.server and xmlrpc.server. The stdlib doesn't have a replacement for the servers, yet.
Source: https://github.com/python/peps/blob/master/pep-0594.rst