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

Lines changed: 0 additions & 564 deletions
This file was deleted.

Doc/library/cgitb.rst

Lines changed: 0 additions & 89 deletions
This file was deleted.

Doc/library/security_warnings.rst

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 30 additions & 0 deletions
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

0 commit comments

Comments
 (0)