From a1774de30e6ee9afcfac0013fbec4ee525bee2e5 Mon Sep 17 00:00:00 2001 From: Benedek Racz Date: Tue, 4 Feb 2020 12:00:46 +0100 Subject: [PATCH] ok both? --- wexpect/host.py | 5 +++++ wexpect/legacy_wexpect.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wexpect/host.py b/wexpect/host.py index adfbe8b..f6576be 100644 --- a/wexpect/host.py +++ b/wexpect/host.py @@ -76,6 +76,7 @@ import signal import socket import logging +import windll import pywintypes import win32process import win32con @@ -136,6 +137,7 @@ class SpawnBase: self.timeout = timeout self.delimiter = EOF self.cwd = cwd + self.codepage = codepage self.env = env self.echo = echo self.maxread = maxread # max bytes to read at one time into buffer @@ -223,10 +225,13 @@ class SpawnBase: else: python_executable = os.path.join(os.path.dirname(sys.executable), 'python.exe') + cp = self.codepage or windll.kernel32.GetACP() + self.console_class_parameters.update({ 'host_pid': self.host_pid, 'local_echo': self.echo, 'interact': self.interact_state, + 'cp': cp, 'just_init': True }) console_class_parameters_kv_pairs = [f'{k}={v}' for k,v in self.console_class_parameters.items() ] diff --git a/wexpect/legacy_wexpect.py b/wexpect/legacy_wexpect.py index 5d57288..82cd92f 100644 --- a/wexpect/legacy_wexpect.py +++ b/wexpect/legacy_wexpect.py @@ -633,7 +633,7 @@ class Wtty: ' '.join(pyargs), f"import sys; sys.path = {spath} + sys.path;" f"args = {args}; import wexpect;" - f"wexpect.ConsoleReaderPipe(wexpect.join_args(args), {pid}, just_init=True)" + f"wexpect.ConsoleReaderPipe(wexpect.join_args(args), {pid}, cp={cp}, just_init=True)" ) logger.info(f'CreateProcess: {commandLine}')