Stop using the cgi module deprecated in Python 3.11
This commit is contained in:
parent
f20d8182ad
commit
65a417e586
|
@ -0,0 +1,57 @@
|
|||
From 204779b7732a403e819df9a12b8f605c0c666e06 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FVille=3D20Skytt=3DC3=3DA4=3F=3D?=
|
||||
<ville.skytta@iki.fi>
|
||||
Date: Mon, 16 May 2022 08:48:31 +0200
|
||||
Subject: [PATCH] Stop using the cgi module, deprecated in Python 3.11 per PEP
|
||||
594 (#6708)
|
||||
|
||||
* Stop using the cgi module, deprecated in Python 3.11 per PEP 594
|
||||
|
||||
https://peps.python.org/pep-0594/#cgi
|
||||
|
||||
* Simplify creating params dict
|
||||
|
||||
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
|
||||
|
||||
* Create 6708.misc
|
||||
|
||||
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
|
||||
---
|
||||
aiohttp/helpers.py | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py
|
||||
index 536d219..f30f76b 100644
|
||||
--- a/aiohttp/helpers.py
|
||||
+++ b/aiohttp/helpers.py
|
||||
@@ -3,7 +3,6 @@
|
||||
import asyncio
|
||||
import base64
|
||||
import binascii
|
||||
-import cgi
|
||||
import datetime
|
||||
import functools
|
||||
import inspect
|
||||
@@ -17,6 +16,7 @@ import warnings
|
||||
import weakref
|
||||
from collections import namedtuple
|
||||
from contextlib import suppress
|
||||
+from email.parser import HeaderParser
|
||||
from email.utils import parsedate
|
||||
from math import ceil
|
||||
from pathlib import Path
|
||||
@@ -756,7 +756,10 @@ class HeadersMixin:
|
||||
self._content_type = "application/octet-stream"
|
||||
self._content_dict = {}
|
||||
else:
|
||||
- self._content_type, self._content_dict = cgi.parse_header(raw)
|
||||
+ msg = HeaderParser().parsestr("Content-Type: " + raw)
|
||||
+ self._content_type = msg.get_content_type()
|
||||
+ params = msg.get_params()
|
||||
+ self._content_dict = dict(params[1:]) # First element is content type again
|
||||
|
||||
@property
|
||||
def content_type(self) -> str:
|
||||
--
|
||||
2.33.1
|
||||
|
|
@ -15,6 +15,8 @@ Source0: %{pypi_source}
|
|||
Patch: 0001-Unbundle-llhttp.patch
|
||||
# https://github.com/aio-libs/aiohttp/commit/936e682d1ab6c833b3e5f0cc3596882cb9cb2444
|
||||
Patch: 0002-Fix-pytest.warns-None-usage-deprecated-in-pytest-7-6.patch
|
||||
# https://github.com/aio-libs/aiohttp/pull/6734
|
||||
Patch: 0003-Stop-using-the-cgi-module-deprecated-in-Python-3.11.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
|
||||
|
|
Loading…
Reference in New Issue