Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cherry-pick b151a1e into branch2.2.

Original commit message:

Add a version check for the curses unicode hack so it won't break when
python 3.2.3 or 3.3 are released.

Closes #450.
  • Loading branch information...
commit 15798a1d6a724e6077ecdc24bfd99298ead8f0c2 1 parent c1f72d5
@bdarnell bdarnell authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 tornado/options.py
View
17 tornado/options.py
@@ -354,12 +354,17 @@ def __init__(self, color, *args, **kwargs):
logging.Formatter.__init__(self, *args, **kwargs)
self._color = color
if color:
- # The curses module has some str/bytes confusion in python3.
- # Most methods return bytes, but only accept strings.
- # The explict calls to unicode() below are harmless in python2,
- # but will do the right conversion in python3.
- fg_color = unicode(curses.tigetstr("setaf") or
- curses.tigetstr("setf") or "", "ascii")
+ # The curses module has some str/bytes confusion in
+ # python3. Until version 3.2.3, most methods return
+ # bytes, but only accept strings. In addition, we want to
+ # output these strings with the logging module, which
+ # works with unicode strings. The explicit calls to
+ # unicode() below are harmless in python2 but will do the
+ # right conversion in python 3.
+ fg_color = (curses.tigetstr("setaf") or
+ curses.tigetstr("setf") or "")
+ if (3, 0) < sys.version_info < (3, 2, 3):
+ fg_color = unicode(fg_color, "ascii")
self._colors = {
logging.DEBUG: unicode(curses.tparm(fg_color, 4), # Blue
"ascii"),
Please sign in to comment.
Something went wrong with that request. Please try again.