Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41139: Deprecate cgi.log(). #25625

Merged
merged 3 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,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
=======
Expand Down
5 changes: 4 additions & 1 deletion Lib/cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import html
import locale
import tempfile
import warnings

__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
"parse_header", "test", "print_exception", "print_environ",
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
Expand Down Expand Up @@ -220,6 +221,7 @@ def test_separator(self):
else:
self.assertEqual(fs.getvalue(key), expect_val[0])

@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_log(self):
cgi.log("Testing")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate undocumented ``cgi.log()`` API.