Skip to content

Commit

Permalink
1. fix the buf of sendcontrol
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddhm1234 committed Jul 13, 2023
1 parent f9002bc commit f94231a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions winpty/ptyprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def sendcontrol(self, char):
a = ord(char)
if 97 <= a <= 122:
a = a - ord('a') + 1
byte = str(bytes([a]))
byte = bytes([a]).decode("ascii")
return self.pty.write(byte), byte
d = {'@': 0, '`': 0,
'[': 27, '{': 27,
Expand All @@ -294,7 +294,7 @@ def sendcontrol(self, char):
if char not in d:
return 0, ''

byte = str(bytes([d[char]]))
byte = bytes([d[char]]).decode("ascii")
return self.pty.write(byte), byte

def sendeof(self):
Expand Down

1 comment on commit f94231a

@ddddhm1234
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the bug in sendcontrol function.
let us take an example of sending ctrl+c through this function,

  • the oiriginal code
byte = str(bytes([0x03]))

the byte would be r"b\x03"

  • the modified code
byte = bytes([0x03]).decode("ascii")

the byte would be "\x03"

Please sign in to comment.