19
19
The :mod: `cgi ` module is deprecated
20
20
(see :pep: `PEP 594 <594#cgi >` for details and alternatives).
21
21
22
+ The :class: `FieldStorage ` class can typically be replaced with
23
+ :func: `urllib.parse.parse_qsl ` for ``GET `` and ``HEAD `` requests,
24
+ and the :mod: `email.message ` module or
25
+ `multipart <https://pypi.org/project/multipart/ >`_ for ``POST `` and ``PUT ``.
26
+ Most :ref: `utility functions <functions-in-cgi-module >` have replacements.
27
+
22
28
--------------
23
29
24
30
Support module for Common Gateway Interface (CGI) scripts.
@@ -293,6 +299,12 @@ algorithms implemented in this module in other circumstances.
293
299
``sys.stdin ``). The *keep_blank_values *, *strict_parsing * and *separator * parameters are
294
300
passed to :func: `urllib.parse.parse_qs ` unchanged.
295
301
302
+ .. deprecated-removed :: 3.11 3.13
303
+ This function, like the rest of the :mod: `cgi ` module, is deprecated.
304
+ It can be replaced by calling :func: `urllib.parse.parse_qs ` directly
305
+ on the desired query string (except for ``multipart/form-data `` input,
306
+ which can be handled as described for :func: `parse_multipart `).
307
+
296
308
297
309
.. function :: parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator="&")
298
310
@@ -316,12 +328,31 @@ algorithms implemented in this module in other circumstances.
316
328
.. versionchanged :: 3.10
317
329
Added the *separator * parameter.
318
330
331
+ .. deprecated-removed :: 3.11 3.13
332
+ This function, like the rest of the :mod: `cgi ` module, is deprecated.
333
+ It can be replaced with the functionality in the :mod: `email ` package
334
+ (e.g. :class: `email.message.EmailMessage `/:class: `email.message.Message `)
335
+ which implements the same MIME RFCs, or with the
336
+ `multipart <https://pypi.org/project/multipart/ >`__ PyPI project.
337
+
319
338
320
339
.. function :: parse_header(string)
321
340
322
341
Parse a MIME header (such as :mailheader: `Content-Type `) into a main value and a
323
342
dictionary of parameters.
324
343
344
+ .. deprecated-removed :: 3.11 3.13
345
+ This function, like the rest of the :mod: `cgi ` module, is deprecated.
346
+ It can be replaced with the functionality in the :mod: `email ` package,
347
+ which implements the same MIME RFCs.
348
+
349
+ For example, with :class: `email.message.EmailMessage `::
350
+
351
+ from email.message import EmailMessage
352
+ msg = EmailMessage()
353
+ msg['content-type'] = 'application/json; charset="utf8"'
354
+ main, params = msg.get_content_type(), msg['content-type'].params
355
+
325
356
326
357
.. function :: test()
327
358
0 commit comments