bpo-47061: deprecate cgi and cgitb (GH-32410)

Part of PEP 594.
This commit is contained in:
Brett Cannon 2022-04-08 17:15:35 -07:00 committed by GitHub
parent 1c8b3b5d66
commit cd29bd13ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 7 deletions

View file

@ -5,6 +5,7 @@ that uses .pypirc in the distutils.command package.
"""
import os
from configparser import RawConfigParser
import warnings
from distutils.cmd import Command
@ -111,7 +112,9 @@ class PyPIRCCommand(Command):
def _read_pypi_response(self, response):
"""Read and decode a PyPI HTTP response."""
import cgi
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
import cgi
content_type = response.getheader('content-type', 'text/plain')
encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii')
return response.read().decode(encoding)