Permalink
Browse files

catch Unicode{De,En}codeError when writing log #102

  • Loading branch information...
fffonion committed Aug 21, 2017
1 parent 486352c commit 22d27413d0ea40ee71182cc962828e3b45978ed3
Showing with 4 additions and 2 deletions.
  1. +4 −2 swjsq.py
View
@@ -176,7 +176,10 @@ def long2hex(l):
def print(s, **kwargs):
line = "%s %s" % (time.strftime('%X', time.localtime(time.time())), s)
logfd.write(line.encode('utf-8'))
try:
logfd.write(line)
except UnicodeEncodeError:
logfd.write(line.encode('utf-8'))
if PY3K:
logfd.write(b'\n')
else:
@@ -201,7 +204,6 @@ def uprint(s, fallback = None, end = None):
print(fallback, end = end)
break
def http_req(url, headers = {}, body = None, encoding = 'utf-8'):
req = urllib2.Request(url)
for k in headers:

0 comments on commit 22d2741

Please sign in to comment.