diff options
author | Georg Brandl <georg@python.org> | 2012-02-06 07:49:13 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-02-06 07:49:13 +0100 |
commit | 8ba7c3fd309800a353f517ce6c374b40c47ca028 (patch) | |
tree | 65e86326f13f601f4e4767c10fd2c9efd9ff6002 /pygments/formatters/terminal.py | |
parent | bb2f7a8bdfce72f688d1c673c087213b73f47447 (diff) | |
download | pygments-8ba7c3fd309800a353f517ce6c374b40c47ca028.tar.gz |
Closes #691: Fix Python 3 terminal highlighting with pygmentize.
Diffstat (limited to 'pygments/formatters/terminal.py')
-rw-r--r-- | pygments/formatters/terminal.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py index 43d03e60..dae00157 100644 --- a/pygments/formatters/terminal.py +++ b/pygments/formatters/terminal.py @@ -9,6 +9,8 @@ :license: BSD, see LICENSE for details. """ +import sys + from pygments.formatter import Formatter from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Token, Whitespace @@ -86,7 +88,8 @@ class TerminalFormatter(Formatter): # hack: if the output is a terminal and has an encoding set, # use that to avoid unicode encode problems if not self.encoding and hasattr(outfile, "encoding") and \ - hasattr(outfile, "isatty") and outfile.isatty(): + hasattr(outfile, "isatty") and outfile.isatty() and \ + sys.version_info < (3,): self.encoding = outfile.encoding return Formatter.format(self, tokensource, outfile) |