Skip to content

ADBDEV-9459: Fix handling unicode characters in commands result#2258

Closed
KnightMurloc wants to merge 2 commits intoadb-6.xfrom
ADBDEV-9459
Closed

ADBDEV-9459: Fix handling unicode characters in commands result#2258
KnightMurloc wants to merge 2 commits intoadb-6.xfrom
ADBDEV-9459

Conversation

@KnightMurloc
Copy link

The result of some commands may contain unicode characters, which leads to a
UnicodeDecodeError when trying to cast it to str in Python 2. Also remove the
futurize changes from the pexpect module since this module already supports
Python 3.

The result of some commands may contain unicode characters, which leads to a
UnicodeDecodeError when trying to cast it to str in Python 2.
Also remove the futurize changes from the pexpect module since this module
already supports Python 3.
@KnightMurloc KnightMurloc marked this pull request as ready for review March 18, 2026 11:11
if GV.opt['-v']:
print('[Info]', strcmd(c))
p = subprocess.Popen(c, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out = p.stdout.read(-1).decode('utf-8')

Choose a reason for hiding this comment

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

Why there will not be problems on python3?

Copy link
Author

Choose a reason for hiding this comment

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

>>> "{}".format("test".encode('utf-8'))
"b'test'"

It may not look that good, but it won't lead to an error. I'm not sure if it's worth adding branching here.

Choose a reason for hiding this comment

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

What the problem with branching? If we get ugly output under python3, is it normal?

Copy link
Author

Choose a reason for hiding this comment

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

This makes the code less readable. But I'm not sure.

Choose a reason for hiding this comment

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

not good, right

>>> "{}".format("test привет".encode('utf-8'))
"b'test \\xd0\\xbf\\xd1\\x80\\xd0\\xb8\\xd0\\xb2\\xd0\\xb5\\xd1\\x82'

@ShapatinAA

This comment was marked as resolved.

@KnightMurloc
Copy link
Author

Fixed with other approach in #2259

@KnightMurloc KnightMurloc deleted the ADBDEV-9459 branch March 20, 2026 14:43
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