Skip to content

ADBDEV-9459: Use use gpsubprocess instead of subprocess#2259

Merged
KnightMurloc merged 5 commits intoadb-6.xfrom
ADBDEV-9459-4
Mar 20, 2026
Merged

ADBDEV-9459: Use use gpsubprocess instead of subprocess#2259
KnightMurloc merged 5 commits intoadb-6.xfrom
ADBDEV-9459-4

Conversation

@KnightMurloc
Copy link

@KnightMurloc KnightMurloc commented Mar 19, 2026

Decoding the results of the subcommands has negative consequences in the
Python 2 environment. In the Python 2, decode returns a unicode string whereas
previously it returned a regular string. This leads to unexpected errors when
trying to convert a unicode string to a byte string if it contains non-ascii
characters. This patch changes the approach. Instead of decoding the results of
the subcommands, the Python 3 environment now uses text mode to work with
subprocesses and files. In most uses of subprocess.Popen has been replaced with
the already existing wrapper gpsubprocess.Popen. A number of improvements have
been made to this end.
It now use a text mode in the Python 3 environment. There is a new wrapper for
check_output that also uses text mode for Python 3.
Remove the futurize changes from the pexpect module since this module already
supports Python 3. In the gpssh module, decode the result only for Python 3 to
avoid the error of converting unicode to ascii when printing.

The gpoperation mechanism has been reworked. Instead of sending raw pickled
serialized data, this data is now sent in base64 format. This was done so that
the data could be sent in text mode.
In gpssh, the decoding of the result is only for Python 3. In Python 2,
outputting unicode strings via print can lead to an error.

Decoding the results of the subcommands has negative consequences in the
Python 2 environment. In the Python 2, decode returns a unicode string whereas
previously it returned a regular string. This leads to unexpected errors when
trying to convert a unicode string to a byte string if it contains non-ascii
characters. This patch changes the approach. Instead of decoding the results of
the subcommands, the Python 3 environment now uses text mode to work with
subprocesses and files. In most uses of subprocess.Popen has been replaced with
the already existing wrapper gpsubprocess.Popen. A number of improvements have
been made to this end.
It now use a text mode in the Python 3 environment. There is a new wrapper for
check_output that also uses text mode for Python 3.

The gpoperation mechanism has been reworked. Instead of sending raw pickled
serialized data, this data is now sent in base64 format. This was done so that
the data could be sent in text mode.
In gpssh, the decoding of the result is only for Python 3. In Python 2,
outputting unicode strings via print can lead to an error.
@KnightMurloc KnightMurloc marked this pull request as ready for review March 20, 2026 05:25
@KnightMurloc KnightMurloc merged commit 952567f into adb-6.x Mar 20, 2026
5 checks passed
@KnightMurloc KnightMurloc deleted the ADBDEV-9459-4 branch March 20, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants