Skip to content

Commit

Permalink
Merge pull request #6 from amullins83/master
Browse files Browse the repository at this point in the history
Fixed encoding/decoding on python3
  • Loading branch information
Greg Williams committed Oct 23, 2013
2 parents 40558b6 + a5ad13e commit 181ce89
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions python3/rake.py
Expand Up @@ -218,19 +218,23 @@ def append_data(self, proc, data):
return

try:
str = data.decode(self.encoding)
except:
str = "[Decode error - output not " + self.encoding + "]"
if type(data) is str:
text = data
elif type(data) is type(b"test"):
text = data.decode(self.encoding)
except Exception as e:
text = "[Decode error - output not " + self.encoding + "]"
text += "\n Error: " + str(e) + "\n"
proc = None

# Normalize newlines, Sublime Text always uses a single \n separator
# in memory.
str = str.replace('\r\n', '\n').replace('\r', '\n')
text = text.replace('\r\n', '\n').replace('\r', '\n')

self.output_view.run_command('append', {'characters': str, 'force': True, 'scroll_to_end': True})
self.output_view.run_command('append', {'characters': text, 'force': True, 'scroll_to_end': True})

def append_string(self, proc, str):
self.append_data(proc, str.encode(self.encoding))
def append_string(self, proc, text):
self.append_data(proc, text.encode(self.encoding))

def finish(self, proc):
if not self.quiet:
Expand Down

0 comments on commit 181ce89

Please sign in to comment.