Skip to content

Commit f82f9ce

Browse files
author
Mathieu Dupuy
authored
Remove python2 support in logging cookbook example. (GH-32362)
1 parent a69a4a9 commit f82f9ce

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,22 +1788,15 @@ Python used.
17881788
If you need more specialised processing, you can use a custom JSON encoder,
17891789
as in the following complete example::
17901790

1791-
from __future__ import unicode_literals
1792-
17931791
import json
17941792
import logging
17951793

1796-
# This next bit is to ensure the script runs unchanged on 2.x and 3.x
1797-
try:
1798-
unicode
1799-
except NameError:
1800-
unicode = str
18011794

18021795
class Encoder(json.JSONEncoder):
18031796
def default(self, o):
18041797
if isinstance(o, set):
18051798
return tuple(o)
1806-
elif isinstance(o, unicode):
1799+
elif isinstance(o, str):
18071800
return o.encode('unicode_escape').decode('ascii')
18081801
return super().default(o)
18091802

0 commit comments

Comments
 (0)