[FIX] TEST of test_command_list_split, escape character change; [FIX] process killing. Based on issue: Pywin32-224 TerminateProcess Function Moved #5

This commit is contained in:
Benedek Racz 2019-07-29 11:49:39 +02:00
parent 01898e5087
commit d3caa273d6
3 changed files with 8 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import os
here = os.path.dirname(os.path.abspath(__file__))
wexpectPath = os.path.dirname(here)
sys.path.insert(0, wexpectPath)
#sys.path.insert(0, wexpectPath)
import wexpect

View File

@ -29,10 +29,10 @@ class SplitCommandLineTestCase(PexpectTestCase.PexpectTestCase):
assert len(wexpect.split_command_line(r'one two')) == 2
assert len(wexpect.split_command_line(r'one two')) == 2
assert len(wexpect.split_command_line(r'one two')) == 2
assert len(wexpect.split_command_line(r'one\ one')) == 1
assert len(wexpect.split_command_line(r'one^ one')) == 1
assert len(wexpect.split_command_line('\'one one\'')) == 1
assert len(wexpect.split_command_line(r'one\"one')) == 1
assert len(wexpect.split_command_line(r'This\' is a\'\ test')) == 3
assert len(wexpect.split_command_line(r"This^' is a^'^ test")) == 3
if __name__ == '__main__':
unittest.main()

View File

@ -1855,6 +1855,9 @@ class spawn_windows (spawn_unix, object):
def kill(self, sig):
"""Sig == sigint for ctrl-c otherwise the child is terminated."""
if not self.isalive():
return
if sig == signal.SIGINT:
self.wtty.sendintr()
else:
@ -2108,8 +2111,8 @@ class Wtty:
def terminate_child(self):
"""Terminate the child process."""
win32api.win32process.TerminateProcess(self.__childProcess, 1)
win32api.TerminateProcess(self.__childProcess, 1)
# win32api.win32process.TerminateProcess(self.__childProcess, 1)
def createKeyEvent(self, char):
"""Creates a single key record corrosponding to
@ -2842,7 +2845,6 @@ def join_args(args):
return ' '.join(commandline)
def split_command_line(command_line, escape_char = '^'):
"""This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I