Hermann Riemann schrieb:
In
https://docs.python.org/3.11/whatsnew/3.11.html
steht unter PEP 594 led to the deprecations of the following modules slated for removal in Python 3.13:
cgi und cgitb
Ich benutze die beiden Funktionen meist um Daten, die in html zwischen <form> und </form> eingegeben werden, auszuwerten.
Auf was müsste ich umstellen?
Im "PEP 594" stehen die Gründe für die vorgesehene Entfernung der dort genannten Module und vorgeschlagene Ersatzlösungen. Für cgi und cgitb gibt es keinen unmittelbaren Ersatz. Vielmehr heißt es dazu: [1] | cgi | | The cgi module is a support module for Common Gateway Interface (CGI) | scripts. CGI is deemed as inefficient because every incoming request is | handled in a new process. PEP 206 considers the module as: | | "[…] designed poorly and are now near-impossible to fix (cgi) […]" Das ist der Grund für die vorgesehene Entfernung. | Replacements for the various parts of cgi which are not directly related | to executing code are: | | * parse with urllib.parse.parse_qs (parse is just a wrapper) | * parse_header with email.message.Message (see example below) | * parse_multipart with email.message.Message (same MIME RFCs) | * FieldStorage/MiniFieldStorage has no direct replacement, but can | * typically be replaced by using multipart (for POST and PUT requests) | or urllib.parse.parse_qsl (for GET and HEAD requests) | * valid_boundary (undocumented) with re.compile("^[ -~]{0,200}[!-~]$") | | As an explicit example of how close parse_header and | email.message.Message are: | | >>> from cgi import parse_header | >>> from email.message import Message | >>> parse_header(h) | ('application/json', {'charset': 'utf8'}) | >>> m = Message() | >>> m['content-type'] = h | >>> m.get_params() | [('application/json', ''), ('charset', 'utf8')] | >>> m.get_param('charset') | 'utf8' | |cgitb | | The cgitb module is a helper for the cgi module for configurable | tracebacks. | | The cgitb module is not used by any major Python web framework (Django, | Pyramid, Plone, Flask, CherryPy, or Bottle). Only Paste uses it in an | optional debugging middleware. -thh [1] Webseiten vorlesen ist irgendwie doof.