From 7338b8364d4def72835d80c6315afbe5c96b20fd Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 9 Jan 2023 03:34:06 +0100 Subject: =?UTF-8?q?Revert=20"=F0=9F=94=A7=20Stop=20using=20the=20`cgi`=20s?= =?UTF-8?q?tdlib=20module"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6b7c2cdc91ca5ba1f6cf3e5d9e8e386266c64ce6. --- CHANGES.rst | 6 ------ cherrypy/lib/httputil.py | 9 ++------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 641976d4..35b3f895 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,3 @@ -v(next) -------- - -* Removed the use of :mod:`cgi` deprecated in Python 3.11 - -- by :user:`webknjaz`. - v18.8.0 ------- diff --git a/cherrypy/lib/httputil.py b/cherrypy/lib/httputil.py index f852cbd6..ced310a0 100644 --- a/cherrypy/lib/httputil.py +++ b/cherrypy/lib/httputil.py @@ -12,8 +12,8 @@ import email.utils import re import builtins from binascii import b2a_base64 +from cgi import parse_header from email.header import decode_header -from email.message import EmailMessage as _EmailMessage from http.server import BaseHTTPRequestHandler from urllib.parse import unquote_plus @@ -155,12 +155,7 @@ class HeaderElement(object): @staticmethod def parse(elementstr): """Transform 'token;key=val' to ('token', {'key': 'val'}).""" - msg = _EmailMessage() - msg['content-type'] = elementstr - - initial_value = msg.get_content_type() - params = dict(msg['content-type'].params) - + initial_value, params = parse_header(elementstr) return initial_value, params @classmethod -- cgit v1.2.1