Skip to content

Commit

Permalink
!fixup python3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jodok committed Jun 16, 2018
1 parent 6486095 commit 9c703ca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion colorama/ansitowin32.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
if windll is not None:
winterm = WinTerm()

is_python2 = sys.version_info.major == 2


def is_stream_closed(stream):
return not hasattr(stream, 'closed') or stream.closed
Expand Down Expand Up @@ -173,7 +175,7 @@ def write_and_convert(self, text):

def write_plain_text(self, text, start, end):
if start < end:
if isinstance(text, unicode):
if is_python2 and isinstance(text, unicode):
self.wrapped.write(text[start:end].encode('ascii', 'ignore'))
else:
self.wrapped.write(text[start:end])
Expand Down

0 comments on commit 9c703ca

Please sign in to comment.