summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
authorMathieu Dupuy <mathieu.dupuy@critizr.com>2022-04-06 16:57:54 (GMT)
committerGitHub <noreply@github.com>2022-04-06 16:57:54 (GMT)
commitf82f9ce3239b9a7e6ffa278658dd9858f64a3c14 (patch)
tree3e45ebe70e45b0c2f56aac86fc56d75d6f6fefe5 /Doc/howto
parenta69a4a917c436579c2c4112081ea86a70f1f05d3 (diff)
downloadcpython-f82f9ce3239b9a7e6ffa278658dd9858f64a3c14.zip
cpython-f82f9ce3239b9a7e6ffa278658dd9858f64a3c14.tar.gz
cpython-f82f9ce3239b9a7e6ffa278658dd9858f64a3c14.tar.bz2
Remove python2 support in logging cookbook example. (GH-32362)
Diffstat (limited to 'Doc/howto')
-rw-r--r--Doc/howto/logging-cookbook.rst9
1 files changed, 1 insertions, 8 deletions
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
index f0d9449..7042792 100644
--- a/Doc/howto/logging-cookbook.rst
+++ b/Doc/howto/logging-cookbook.rst
@@ -1788,22 +1788,15 @@ Python used.
If you need more specialised processing, you can use a custom JSON encoder,
as in the following complete example::
- from __future__ import unicode_literals
-
import json
import logging
- # This next bit is to ensure the script runs unchanged on 2.x and 3.x
- try:
- unicode
- except NameError:
- unicode = str
class Encoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, set):
return tuple(o)
- elif isinstance(o, unicode):
+ elif isinstance(o, str):
return o.encode('unicode_escape').decode('ascii')
return super().default(o)