diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-06-12 09:59:04 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-10-01 21:00:03 -0400 |
commit | adeb869f560ed876ef44f4c950e5798090948276 (patch) | |
tree | 07d40f353136d3f0178780cc244003cb89e9e404 /klippy/gcode.py | |
parent | 1717263b5a55d55b0b8dbbffbd3ce45c8d512660 (diff) | |
download | kutter-adeb869f560ed876ef44f4c950e5798090948276.tar.gz kutter-adeb869f560ed876ef44f4c950e5798090948276.tar.xz kutter-adeb869f560ed876ef44f4c950e5798090948276.zip |
gcode: Convert to Python3 string encoding
The error checking is not complete in this change - the code should
handle the case where an input string is not valid utf8.
The code will continue to run on Python2 after this change, however
the execution time on Python2 is measurably slower after making this
change.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r-- | klippy/gcode.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py index 97621cb9..17bf17e4 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -387,7 +387,7 @@ class GCodeIO: return self.input_log.append((eventtime, data)) self.bytes_read += len(data) - lines = data.split('\n') + lines = data.decode().split('\n') lines[0] = self.partial_input + lines[0] self.partial_input = lines.pop() pending_commands = self.pending_commands @@ -427,7 +427,7 @@ class GCodeIO: def _respond_raw(self, msg): if self.pipe_is_active: try: - os.write(self.fd, msg+"\n") + os.write(self.fd, (msg+"\n").encode()) except os.error: logging.exception("Write g-code response") self.pipe_is_active = False |