We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a69a4a9 commit f82f9ceCopy full SHA for f82f9ce
1 file changed
Doc/howto/logging-cookbook.rst
@@ -1788,22 +1788,15 @@ Python used.
1788
If you need more specialised processing, you can use a custom JSON encoder,
1789
as in the following complete example::
1790
1791
- from __future__ import unicode_literals
1792
-
1793
import json
1794
import logging
1795
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
1801
1802
class Encoder(json.JSONEncoder):
1803
def default(self, o):
1804
if isinstance(o, set):
1805
return tuple(o)
1806
- elif isinstance(o, unicode):
+ elif isinstance(o, str):
1807
return o.encode('unicode_escape').decode('ascii')
1808
return super().default(o)
1809
0 commit comments