diff options
Diffstat (limited to 'pygments/formatters')
-rw-r--r-- | pygments/formatters/terminal.py | 5 | ||||
-rw-r--r-- | pygments/formatters/terminal256.py | 5 |
2 files changed, 8 insertions, 2 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) diff --git a/pygments/formatters/terminal256.py b/pygments/formatters/terminal256.py index 3105a651..cbd30be1 100644 --- a/pygments/formatters/terminal256.py +++ b/pygments/formatters/terminal256.py @@ -24,6 +24,8 @@ # black-on-while, so colors like "white background" need to be converted # to "white background, black foreground", etc... +import sys + from pygments.formatter import Formatter @@ -185,7 +187,8 @@ class Terminal256Formatter(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) |