FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-92611: Add details on replacements for cgi utility funcs by CAM-Gerlach · Pull Request #92792 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
31 changes: 31 additions & 0 deletions Doc/library/cgi.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
The :mod:`cgi` module is deprecated
(see :pep:`PEP 594 <594#cgi>` for details and alternatives).

The :class:`FieldStorage` class can typically be replaced with
:func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests,
and the :mod:`email.message` module or
`multipart <https://pypi.org/project/multipart/>`_ for ``POST`` and ``PUT``.
Most :ref:`utility functions <functions-in-cgi-module>` have replacements.

--------------

Support module for Common Gateway Interface (CGI) scripts.
Expand Down Expand Up @@ -293,6 +299,12 @@ algorithms implemented in this module in other circumstances.
``sys.stdin``). The *keep_blank_values*, *strict_parsing* and *separator* parameters are
passed to :func:`urllib.parse.parse_qs` unchanged.

.. deprecated-removed:: 3.11 3.13
This function, like the rest of the :mod:`cgi` module, is deprecated.
It can be replaced by calling :func:`urllib.parse.parse_qs` directly
on the desired query string (except for ``multipart/form-data`` input,
which can be handled as described for :func:`parse_multipart`).


.. function:: parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator="&")

Expand All @@ -316,12 +328,31 @@ algorithms implemented in this module in other circumstances.
.. versionchanged:: 3.10
Added the *separator* parameter.

.. deprecated-removed:: 3.11 3.13
This function, like the rest of the :mod:`cgi` module, is deprecated.
It can be replaced with the functionality in the :mod:`email` package
(e.g. :class:`email.message.EmailMessage`/:class:`email.message.Message`)
which implements the same MIME RFCs, or with the
`multipart <https://pypi.org/project/multipart/>`__ PyPI project.


.. function:: parse_header(string)

Parse a MIME header (such as :mailheader:`Content-Type`) into a main value and a
dictionary of parameters.

.. deprecated-removed:: 3.11 3.13
This function, like the rest of the :mod:`cgi` module, is deprecated.
It can be replaced with the functionality in the :mod:`email` package,
which implements the same MIME RFCs.

For example, with :class:`email.message.EmailMessage`::

from email.message import EmailMessage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should this be three spaces instead of four?

msg = EmailMessage()
msg['content-type'] = 'application/json; charset="utf8"'
main, params = msg.get_content_type(), msg['content-type'].params


.. function:: test()

Expand Down

Back | FazBrowse Home | New Git URL