Skip to content

Commit c0001e7

Browse files
committed
Explain how to port existing code
1 parent c1ea7ba commit c0001e7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,31 @@ Removed
117117

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

122147

0 commit comments

Comments
 (0)