File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 67
67
unicode_string = str
68
68
byte_string = bytes
69
69
70
+ # Compatibility with Python 2.6 which doesn't have logging.NullHandler.
71
+ try :
72
+ from logging import NullHandler
73
+ except ImportError :
74
+
75
+ # This class was copied from the Python standard library, specifically
76
+ # https://hg.python.org/cpython/file/771f28686022/Lib/logging/__init__.py#l1670
77
+ class NullHandler (logging .Handler ):
78
+
79
+ def handle (self , record ):
80
+ pass
81
+
82
+ def emit (self , record ):
83
+ pass
84
+
85
+ def createLock (self ):
86
+ self .lock = None
87
+
70
88
# Try to import the Levenshtein module, don't error out if it's not installed.
71
89
try :
72
90
import Levenshtein
@@ -110,6 +128,8 @@ def init_logging(self):
110
128
self .logger .setLevel (logging .INFO )
111
129
if all (map (os .isatty , (0 , 1 , 2 ))):
112
130
self .logger .addHandler (logging .StreamHandler (sys .stderr ))
131
+ else :
132
+ self .logger .addHandler (NullHandler ())
113
133
114
134
def parse_args (self ):
115
135
"""Parse the command line arguments."""
You can’t perform that action at this time.
0 commit comments