Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
commit 1597c382c57210fba992c3e16b95cbfd243e700f 2 parents 2836544 + 09fa07e
@xadhoom authored
Showing with 12 additions and 5 deletions.
  1. +6 −3 twistar/dbconfig/base.py
  2. +6 −2 twistar/tests/test_dbconfig.py
View
9 twistar/dbconfig/base.py
@@ -25,8 +25,11 @@ class InteractionBase:
includeBlankInInsert = True
- def _maybe_encode(self, s, encoding='utf-8'):
- if isinstance(s, basestring):
+ def logEncode(self, s, encoding='utf-8'):
+ """
+ Encode the given string if necessary for printing to logs.
+ """
+ if isinstance(s, unicode):
return s.encode(encoding)
return str(s)
@@ -40,7 +43,7 @@ def log(self, query, args, kwargs):
return
log.msg("TWISTAR query: %s" % query)
if len(args) > 0:
- log.msg("TWISTAR args: %s" % ",".join(map(self._maybe_encode, *args)))
+ log.msg("TWISTAR args: %s" % ",".join(map(self.logEncode, *args)))
elif len(kwargs) > 0:
log.msg("TWISTAR kargs: %s" % str(kwargs))
View
8 twistar/tests/test_dbconfig.py
@@ -142,10 +142,14 @@ def test_colname_escaping(self):
def test_unicode_logging(self):
- ustr = u'\N{SNOWMAN}'
-
InteractionBase.LOG = True
+
+ ustr = u'\N{SNOWMAN}'
InteractionBase().log(ustr, [ustr], {ustr: ustr})
+
+ ustr = '\xc3\xa8'
+ InteractionBase().log(ustr, [ustr], {ustr: ustr})
+
InteractionBase.LOG = False

0 comments on commit 1597c38

Please sign in to comment.
Something went wrong with that request. Please try again.