Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit ad7307b

Browse files
Fix IGuestProcess.execute() on Python 3 ...
... where stdout and stderr are of type `memoryview` and `str(memoryview)` turns to `'<memory 0x012345ABCDEF...>'`.
1 parent 1d62528 commit ad7307b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

virtualbox/library_ext/guest_session.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ def execute(self, command, arguments=[], stdin="", environment=[],
4545
def read_out(process, flags, stdout, stderr):
4646
if library.ProcessCreateFlag.wait_for_std_err in flags:
4747
process.wait_for(int(library.ProcessWaitResult.std_err))
48-
e = str(process.read(2, 65000, 0))
48+
e = process.read(2, 65000, 0)
49+
if isinstance(e, memoryview):
50+
e = bytes(e)
4951
stderr.append(e)
5052
if library.ProcessCreateFlag.wait_for_std_out in flags:
5153
process.wait_for(int(library.ProcessWaitResult.std_out))
52-
o = str(process.read(1, 65000, 0))
54+
o = process.read(1, 65000, 0)
55+
if isinstance(o, memoryview):
56+
o = bytes(o)
5357
stdout.append(o)
5458

5559
process = self.process_create_ex(command,
@@ -85,7 +89,7 @@ def read_out(process, flags, stdout, stderr):
8589
# make sure we have read the remainder of the out
8690
read_out(process, flags, stdout, stderr)
8791

88-
return process, "".join(stdout), "".join(stderr)
92+
return process, b"".join(stdout), b"".join(stderr)
8993

9094
def makedirs(self, path, mode=0x777):
9195
"Super-mkdir: create a leaf directory and all intermediate ones."

0 commit comments

Comments
 (0)