mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
bpo-47061: deprecate cgi and cgitb (GH-32410)
Part of PEP 594.
This commit is contained in:
parent
1c8b3b5d66
commit
cd29bd13ef
8 changed files with 28 additions and 7 deletions
|
@ -834,6 +834,8 @@ Deprecated
|
||||||
|
|
||||||
* :mod:`aifc`
|
* :mod:`aifc`
|
||||||
* :mod:`audioop`
|
* :mod:`audioop`
|
||||||
|
* :mod:`cgi`
|
||||||
|
* :mod:`cgitb`
|
||||||
|
|
||||||
(Contributed by Brett Cannon in :issue:`47061`.)
|
(Contributed by Brett Cannon in :issue:`47061`.)
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ __all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
|
||||||
"print_form", "print_directory", "print_arguments",
|
"print_form", "print_directory", "print_arguments",
|
||||||
"print_environ_usage"]
|
"print_environ_usage"]
|
||||||
|
|
||||||
|
|
||||||
|
warnings._deprecated(__name__, remove=(3,13))
|
||||||
|
|
||||||
# Logging support
|
# Logging support
|
||||||
# ===============
|
# ===============
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,12 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
import tokenize
|
import tokenize
|
||||||
import traceback
|
import traceback
|
||||||
|
import warnings
|
||||||
from html import escape as html_escape
|
from html import escape as html_escape
|
||||||
|
|
||||||
|
warnings._deprecated(__name__, remove=(3, 13))
|
||||||
|
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
"""Return a string that resets the CGI and browser to a known state."""
|
"""Return a string that resets the CGI and browser to a known state."""
|
||||||
return '''<!--: spam
|
return '''<!--: spam
|
||||||
|
|
|
@ -5,6 +5,7 @@ that uses .pypirc in the distutils.command package.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from configparser import RawConfigParser
|
from configparser import RawConfigParser
|
||||||
|
import warnings
|
||||||
|
|
||||||
from distutils.cmd import Command
|
from distutils.cmd import Command
|
||||||
|
|
||||||
|
@ -111,7 +112,9 @@ class PyPIRCCommand(Command):
|
||||||
|
|
||||||
def _read_pypi_response(self, response):
|
def _read_pypi_response(self, response):
|
||||||
"""Read and decode a PyPI HTTP 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')
|
content_type = response.getheader('content-type', 'text/plain')
|
||||||
encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii')
|
encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii')
|
||||||
return response.read().decode(encoding)
|
return response.read().decode(encoding)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import cgi
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -8,6 +7,9 @@ from io import StringIO, BytesIO
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import warnings_helper
|
from test.support import warnings_helper
|
||||||
|
|
||||||
|
cgi = warnings_helper.import_deprecated("cgi")
|
||||||
|
|
||||||
|
|
||||||
class HackedSysModule:
|
class HackedSysModule:
|
||||||
# The regression test will have real values in sys.argv, which
|
# The regression test will have real values in sys.argv, which
|
||||||
# will completely confuse the test of the cgi module
|
# will completely confuse the test of the cgi module
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from test.support.os_helper import temp_dir
|
from test.support.os_helper import temp_dir
|
||||||
from test.support.script_helper import assert_python_failure
|
from test.support.script_helper import assert_python_failure
|
||||||
|
from test.support.warnings_helper import import_deprecated
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import cgitb
|
cgitb = import_deprecated("cgitb")
|
||||||
|
|
||||||
class TestCgitb(unittest.TestCase):
|
class TestCgitb(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -570,14 +570,19 @@ print("Hello World")
|
||||||
|
|
||||||
cgi_file2 = """\
|
cgi_file2 = """\
|
||||||
#!%s
|
#!%s
|
||||||
import cgi
|
import os
|
||||||
|
import sys
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
print("Content-type: text/html")
|
print("Content-type: text/html")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
form = cgi.FieldStorage()
|
content_length = int(os.environ["CONTENT_LENGTH"])
|
||||||
print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
|
query_string = sys.stdin.buffer.read(content_length)
|
||||||
form.getfirst("bacon")))
|
params = {key.decode("utf-8"): val.decode("utf-8")
|
||||||
|
for key, val in urllib.parse.parse_qsl(query_string)}
|
||||||
|
|
||||||
|
print("%%s, %%s, %%s" %% (params["spam"], params["eggs"], params["bacon"]))
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cgi_file4 = """\
|
cgi_file4 = """\
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Deprecate cgi and cgitb.
|
Loading…
Add table
Add a link
Reference in a new issue