diff options
author | Inada Naoki <songofacandy@gmail.com> | 2021-04-29 02:36:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 02:36:04 (GMT) |
commit | e52ab42cedd2a5ef4c3c1a47d0cf96a8f06d051f (patch) | |
tree | 6c10f217b202ed648c88eb2d23eeb4ba3088eb64 | |
parent | a69256527f93d2aa32e76658deab829e324d97b6 (diff) | |
download | cpython-e52ab42cedd2a5ef4c3c1a47d0cf96a8f06d051f.zip cpython-e52ab42cedd2a5ef4c3c1a47d0cf96a8f06d051f.tar.gz cpython-e52ab42cedd2a5ef4c3c1a47d0cf96a8f06d051f.tar.bz2 |
bpo-41139: Deprecate `cgi.log()` (GH-25625)
-rw-r--r-- | Doc/whatsnew/3.10.rst | 3 | ||||
-rwxr-xr-x | Lib/cgi.py | 5 | ||||
-rw-r--r-- | Lib/test/test_cgi.py | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-04-26-17-47-48.bpo-41139.ROhn1k.rst | 1 |
4 files changed, 10 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 37c1b8a..fa99ce5 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1427,6 +1427,9 @@ Deprecated Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead. (Contributed by Barney Gale in :issue:`39950`.) +* ``cgi.log()`` is deprecated and slated for for removal in Python 3.12. + (Contributed by Inada Naoki in :issue:`41139`.) + Removed ======= @@ -41,6 +41,7 @@ from email.message import Message import html import locale import tempfile +import warnings __all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart", "parse_header", "test", "print_exception", "print_environ", @@ -77,9 +78,11 @@ def initlog(*allargs): """ global log, logfile, logfp + warnings.warn("cgi.log() is deprecated as of 3.10. Use logging instead", + DeprecationWarning, stacklevel=2) if logfile and not logfp: try: - logfp = open(logfile, "a") + logfp = open(logfile, "a", encoding="locale") except OSError: pass if not logfp: diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index 239d975..c1b893d 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -6,6 +6,7 @@ import unittest from collections import namedtuple from io import StringIO, BytesIO from test import support +from test.support import warnings_helper class HackedSysModule: # The regression test will have real values in sys.argv, which @@ -220,6 +221,7 @@ Content-Length: 3 else: self.assertEqual(fs.getvalue(key), expect_val[0]) + @warnings_helper.ignore_warnings(category=DeprecationWarning) def test_log(self): cgi.log("Testing") diff --git a/Misc/NEWS.d/next/Library/2021-04-26-17-47-48.bpo-41139.ROhn1k.rst b/Misc/NEWS.d/next/Library/2021-04-26-17-47-48.bpo-41139.ROhn1k.rst new file mode 100644 index 0000000..5df8929 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-26-17-47-48.bpo-41139.ROhn1k.rst @@ -0,0 +1 @@ +Deprecate undocumented ``cgi.log()`` API. |