Skip to content

Commit 08d5923

Browse files
authored
gh-104773: PEP 594: Remove cgi and cgitb modules (#104775)
* Replace "cgi" with "!cgi" in the Sphinx documentation to avoid warnings on broken references. * test_pyclbr no longer tests the cgi module.
1 parent e561c09 commit 08d5923

24 files changed

+52
-2739
lines changed

Doc/library/cgi.rst

-564
This file was deleted.

Doc/library/cgitb.rst

-89
This file was deleted.

Doc/library/security_warnings.rst

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ The following modules have specific security considerations:
99

1010
* :mod:`base64`: :ref:`base64 security considerations <base64-security>` in
1111
:rfc:`4648`
12-
* :mod:`cgi`: :ref:`CGI security considerations <cgi-security>`
1312
* :mod:`hashlib`: :ref:`all constructors take a "usedforsecurity" keyword-only
1413
argument disabling known insecure and blocked algorithms
1514
<hashlib-usedforsecurity>`

Doc/library/superseded.rst

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ backwards compatibility. They have been superseded by other modules.
1212

1313
aifc.rst
1414
audioop.rst
15-
cgi.rst
16-
cgitb.rst
1715
chunk.rst
1816
crypt.rst
1917
imghdr.rst

Doc/whatsnew/2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ Module changes
10301030

10311031
Lots of improvements and bugfixes were made to Python's extensive standard
10321032
library; some of the affected modules include :mod:`readline`,
1033-
:mod:`ConfigParser`, :mod:`cgi`, :mod:`calendar`, :mod:`posix`, :mod:`readline`,
1033+
:mod:`ConfigParser`, :mod:`!cgi`, :mod:`calendar`, :mod:`posix`, :mod:`readline`,
10341034
:mod:`xmllib`, :mod:`aifc`, :mod:`chunk, wave`, :mod:`random`, :mod:`shelve`,
10351035
and :mod:`nntplib`. Consult the CVS logs for the exact patch-by-patch details.
10361036

Doc/whatsnew/2.6.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1805,15 +1805,15 @@ changes, or look through the Subversion logs for all the details.
18051805
available, instead of restricting itself to protocol 1.
18061806
(Contributed by W. Barnes.)
18071807

1808-
* The :mod:`cgi` module will now read variables from the query string
1808+
* The :mod:`!cgi` module will now read variables from the query string
18091809
of an HTTP POST request. This makes it possible to use form actions
18101810
with URLs that include query strings such as
18111811
"/cgi-bin/add.py?category=1". (Contributed by Alexandre Fiori and
18121812
Nubis; :issue:`1817`.)
18131813

18141814
The :func:`parse_qs` and :func:`parse_qsl` functions have been
1815-
relocated from the :mod:`cgi` module to the :mod:`urlparse` module.
1816-
The versions still available in the :mod:`cgi` module will
1815+
relocated from the :mod:`!cgi` module to the :mod:`urlparse` module.
1816+
The versions still available in the :mod:`!cgi` module will
18171817
trigger :exc:`PendingDeprecationWarning` messages in 2.6
18181818
(:issue:`600362`).
18191819

Doc/whatsnew/3.10.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ query parameter separators in :func:`urllib.parse.parse_qs` and
15081508
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
15091509
newer W3C recommendations, this has been changed to allow only a single
15101510
separator key, with ``&`` as the default. This change also affects
1511-
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
1511+
:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected
15121512
functions internally. For more details, please see their respective
15131513
documentation.
15141514
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)

Doc/whatsnew/3.11.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,9 @@ Modules
17351735
+---------------------+---------------------+---------------------+---------------------+---------------------+
17361736
| :mod:`audioop` | :mod:`crypt` | :mod:`nis` | :mod:`sndhdr` | :mod:`uu` |
17371737
+---------------------+---------------------+---------------------+---------------------+---------------------+
1738-
| :mod:`cgi` | :mod:`imghdr` | :mod:`nntplib` | :mod:`spwd` | :mod:`xdrlib` |
1738+
| :mod:`!cgi` | :mod:`imghdr` | :mod:`nntplib` | :mod:`spwd` | :mod:`xdrlib` |
17391739
+---------------------+---------------------+---------------------+---------------------+---------------------+
1740-
| :mod:`cgitb` | :mod:`mailcap` | :mod:`ossaudiodev` | :mod:`sunau` | |
1740+
| :mod:`!cgitb` | :mod:`mailcap` | :mod:`ossaudiodev` | :mod:`sunau` | |
17411741
+---------------------+---------------------+---------------------+---------------------+---------------------+
17421742

17431743
(Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in

Doc/whatsnew/3.12.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ Modules (see :pep:`594`):
805805

806806
* :mod:`aifc`
807807
* :mod:`audioop`
808-
* :mod:`cgi`
809-
* :mod:`cgitb`
808+
* :mod:`!cgi`
809+
* :mod:`!cgitb`
810810
* :mod:`chunk`
811811
* :mod:`crypt`
812812
* :mod:`imghdr`

Doc/whatsnew/3.13.rst

+30
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,36 @@ Removed
118118
* Remove support for using :class:`pathlib.Path` objects as context managers.
119119
This functionality was deprecated and made a no-op in Python 3.9.
120120

121+
* :pep:`594`: Remove the :mod:`!cgi`` and :mod:`!cgitb` modules,
122+
deprecated in Python 3.11.
123+
124+
* ``cgi.FieldStorage`` can typically be replaced with
125+
:func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the
126+
:mod:`email.message` module or `multipart
127+
<https://pypi.org/project/multipart/>`__ PyPI project for ``POST`` and
128+
``PUT``.
129+
130+
* ``cgi.parse()`` can be replaced by calling :func:`urllib.parse.parse_qs`
131+
directly on the desired query string, except for ``multipart/form-data``
132+
input, which can be handled as described for ``cgi.parse_multipart()``.
133+
134+
* ``cgi.parse_multipart()`` can be replaced with the functionality in the
135+
:mod:`email` package (e.g. :class:`email.message.EmailMessage` and
136+
:class:`email.message.Message`) which implements the same MIME RFCs, or
137+
with the `multipart <https://pypi.org/project/multipart/>`__ PyPI project.
138+
139+
* ``cgi.parse_header()`` can be replaced with the functionality in the
140+
:mod:`email` package, which implements the same MIME RFCs. For example,
141+
with :class:`email.message.EmailMessage`::
142+
143+
from email.message import EmailMessage
144+
msg = EmailMessage()
145+
msg['content-type'] = 'application/json; charset="utf8"'
146+
main, params = msg.get_content_type(), msg['content-type'].params
147+
148+
(Contributed by Victor Stinner in :gh:`104773`.)
149+
150+
121151
Porting to Python 3.13
122152
======================
123153

Doc/whatsnew/3.4.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -2371,11 +2371,11 @@ Changes in the Python API
23712371
3.3.3.
23722372

23732373
* The :attr:`~cgi.FieldStorage.file` attribute is now automatically closed when
2374-
the creating :class:`cgi.FieldStorage` instance is garbage collected. If you
2375-
were pulling the file object out separately from the :class:`cgi.FieldStorage`
2374+
the creating :class:`!cgi.FieldStorage` instance is garbage collected. If you
2375+
were pulling the file object out separately from the :class:`!cgi.FieldStorage`
23762376
instance and not keeping the instance alive, then you should either store the
2377-
entire :class:`cgi.FieldStorage` instance or read the contents of the file
2378-
before the :class:`cgi.FieldStorage` instance is garbage collected.
2377+
entire :class:`!cgi.FieldStorage` instance or read the contents of the file
2378+
before the :class:`!cgi.FieldStorage` instance is garbage collected.
23792379

23802380
* Calling ``read`` or ``write`` on a closed SSL socket now raises an
23812381
informative :exc:`ValueError` rather than the previous more mysterious

Doc/whatsnew/3.6.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ Changes in the Python API
21852185

21862186
* The following modules have had missing APIs added to their :attr:`__all__`
21872187
attributes to match the documented APIs:
2188-
:mod:`calendar`, :mod:`cgi`, :mod:`csv`,
2188+
:mod:`calendar`, :mod:`!cgi`, :mod:`csv`,
21892189
:mod:`~xml.etree.ElementTree`, :mod:`enum`,
21902190
:mod:`fileinput`, :mod:`ftplib`, :mod:`logging`, :mod:`mailbox`,
21912191
:mod:`mimetypes`, :mod:`optparse`, :mod:`plistlib`, :mod:`smtpd`,
@@ -2455,7 +2455,7 @@ query parameter separators in :func:`urllib.parse.parse_qs` and
24552455
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
24562456
newer W3C recommendations, this has been changed to allow only a single
24572457
separator key, with ``&`` as the default. This change also affects
2458-
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
2458+
:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected
24592459
functions internally. For more details, please see their respective
24602460
documentation.
24612461
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)

Doc/whatsnew/3.7.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ query parameter separators in :func:`urllib.parse.parse_qs` and
25672567
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
25682568
newer W3C recommendations, this has been changed to allow only a single
25692569
separator key, with ``&`` as the default. This change also affects
2570-
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
2570+
:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected
25712571
functions internally. For more details, please see their respective
25722572
documentation.
25732573
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)

Doc/whatsnew/3.8.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ The following features and APIs have been removed from Python 3.8:
17741774
to help eliminate confusion as to what Python interpreter the ``pyvenv``
17751775
script is tied to. (Contributed by Brett Cannon in :issue:`25427`.)
17761776

1777-
* ``parse_qs``, ``parse_qsl``, and ``escape`` are removed from the :mod:`cgi`
1777+
* ``parse_qs``, ``parse_qsl``, and ``escape`` are removed from the :mod:`!cgi`
17781778
module. They are deprecated in Python 3.2 or older. They should be imported
17791779
from the ``urllib.parse`` and ``html`` modules instead.
17801780

@@ -2251,7 +2251,7 @@ query parameter separators in :func:`urllib.parse.parse_qs` and
22512251
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
22522252
newer W3C recommendations, this has been changed to allow only a single
22532253
separator key, with ``&`` as the default. This change also affects
2254-
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
2254+
:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected
22552255
functions internally. For more details, please see their respective
22562256
documentation.
22572257
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)

Doc/whatsnew/3.9.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ query parameter separators in :func:`urllib.parse.parse_qs` and
15591559
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
15601560
newer W3C recommendations, this has been changed to allow only a single
15611561
separator key, with ``&`` as the default. This change also affects
1562-
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
1562+
:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected
15631563
functions internally. For more details, please see their respective
15641564
documentation.
15651565
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)

0 commit comments

Comments
 (0)