mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-41139: Deprecate cgi.log()
(GH-25625)
This commit is contained in:
parent
a69256527f
commit
e52ab42ced
4 changed files with 10 additions and 1 deletions
|
@ -1427,6 +1427,9 @@ Deprecated
|
||||||
Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.
|
Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.
|
||||||
(Contributed by Barney Gale in :issue:`39950`.)
|
(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
|
Removed
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -41,6 +41,7 @@ from email.message import Message
|
||||||
import html
|
import html
|
||||||
import locale
|
import locale
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import warnings
|
||||||
|
|
||||||
__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
|
__all__ = ["MiniFieldStorage", "FieldStorage", "parse", "parse_multipart",
|
||||||
"parse_header", "test", "print_exception", "print_environ",
|
"parse_header", "test", "print_exception", "print_environ",
|
||||||
|
@ -77,9 +78,11 @@ def initlog(*allargs):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
global log, logfile, logfp
|
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:
|
if logfile and not logfp:
|
||||||
try:
|
try:
|
||||||
logfp = open(logfile, "a")
|
logfp = open(logfile, "a", encoding="locale")
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
if not logfp:
|
if not logfp:
|
||||||
|
|
|
@ -6,6 +6,7 @@ import unittest
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from io import StringIO, BytesIO
|
from io import StringIO, BytesIO
|
||||||
from test import support
|
from test import support
|
||||||
|
from test.support import warnings_helper
|
||||||
|
|
||||||
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
|
||||||
|
@ -220,6 +221,7 @@ Content-Length: 3
|
||||||
else:
|
else:
|
||||||
self.assertEqual(fs.getvalue(key), expect_val[0])
|
self.assertEqual(fs.getvalue(key), expect_val[0])
|
||||||
|
|
||||||
|
@warnings_helper.ignore_warnings(category=DeprecationWarning)
|
||||||
def test_log(self):
|
def test_log(self):
|
||||||
cgi.log("Testing")
|
cgi.log("Testing")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Deprecate undocumented ``cgi.log()`` API.
|
Loading…
Add table
Add a link
Reference in a new issue