bpo-33843: Remove deprecated stuff in cgi module (GH-7662)
diff --git a/Lib/cgi.py b/Lib/cgi.py
index f82cc6c..b655a05 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -38,16 +38,14 @@
import urllib.parse
from email.parser import FeedParser
from email.message import Message
-from warnings import warn
import html
import locale
import tempfile
-__all__ = ["MiniFieldStorage", "FieldStorage",
- "parse", "parse_qs", "parse_qsl", "parse_multipart",
+__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
"parse_header", "test", "print_exception", "print_environ",
"print_form", "print_directory", "print_arguments",
- "print_environ_usage", "escape"]
+ "print_environ_usage"]
# Logging support
# ===============
@@ -183,21 +181,6 @@
encoding=encoding)
-# parse query string function called from urlparse,
-# this is done in order to maintain backward compatibility.
-
-def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
- """Parse a query given as a string argument."""
- warn("cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead",
- DeprecationWarning, 2)
- return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing)
-
-def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
- """Parse a query given as a string argument."""
- warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead",
- DeprecationWarning, 2)
- return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
-
def parse_multipart(fp, pdict, encoding="utf-8", errors="replace"):
"""Parse multipart input.
@@ -974,18 +957,6 @@
# Utilities
# =========
-def escape(s, quote=None):
- """Deprecated API."""
- warn("cgi.escape is deprecated, use html.escape instead",
- DeprecationWarning, stacklevel=2)
- s = s.replace("&", "&") # Must be done first!
- s = s.replace("<", "<")
- s = s.replace(">", ">")
- if quote:
- s = s.replace('"', """)
- return s
-
-
def valid_boundary(s):
import re
if isinstance(s, bytes):
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index 4f2bba1..b284a0d 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -4,7 +4,6 @@
import sys
import tempfile
import unittest
-import warnings
from collections import namedtuple
from io import StringIO, BytesIO
from test import support
@@ -163,15 +162,6 @@
fs = cgi.FieldStorage(headers={'content-type':'text/plain'})
self.assertRaises(TypeError, bool, fs)
- def test_escape(self):
- # cgi.escape() is deprecated.
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore', r'cgi\.escape',
- DeprecationWarning)
- self.assertEqual("test & string", cgi.escape("test & string"))
- self.assertEqual("<test string>", cgi.escape("<test string>"))
- self.assertEqual(""test string"", cgi.escape('"test string"', True))
-
def test_strict(self):
for orig, expect in parse_strict_test_cases:
# Test basic parsing
@@ -449,20 +439,6 @@
v = gen_result(data, environ)
self.assertEqual(result, v)
- def test_deprecated_parse_qs(self):
- # this func is moved to urllib.parse, this is just a sanity check
- with check_warnings(('cgi.parse_qs is deprecated, use urllib.parse.'
- 'parse_qs instead', DeprecationWarning)):
- self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
- cgi.parse_qs('a=A1&b=B2&B=B3'))
-
- def test_deprecated_parse_qsl(self):
- # this func is moved to urllib.parse, this is just a sanity check
- with check_warnings(('cgi.parse_qsl is deprecated, use urllib.parse.'
- 'parse_qsl instead', DeprecationWarning)):
- self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
- cgi.parse_qsl('a=A1&b=B2&B=B3'))
-
def test_parse_header(self):
self.assertEqual(
cgi.parse_header("text/plain"),