Simplify the unicode type test for python 3

This commit is contained in:
Thomas Nagy 2015-09-28 21:33:48 +02:00
parent c6f98f80db
commit 1205f92a7f
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@
logging, colors, terminal width and pretty-print
"""
import os, re, traceback, sys, types
import os, re, traceback, sys
from waflib import Utils, ansiterm
if not os.environ.get('NOSYNC', False):
@ -43,6 +43,11 @@ colors_lst = {
indicator = '\r\x1b[K%s%s%s'
try:
unicode
except NameError:
unicode = None
def enable_colors(use):
if use == 1:
if not (sys.stderr.isatty() or sys.stdout.isatty()):
@ -150,7 +155,7 @@ class log_handler(logging.StreamHandler):
def emit_override(self, record, **kw):
self.terminator = getattr(record, 'terminator', '\n')
stream = self.stream
if hasattr(types, "UnicodeType"):
if unicode:
# python2
msg = self.formatter.format(record)
fs = '%s' + self.terminator