Skip to content

[3.7] bpo-34537: Fix test_gdb:test_strings with LC_ALL=C (GH-9483) #9485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Lib/test/test_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,20 @@ def test_bytes(self):

def test_strings(self):
'Verify the pretty-printing of unicode strings'
encoding = locale.getpreferredencoding()
# We cannot simply call locale.getpreferredencoding() here,
# as GDB might have been linked against a different version
# of Python with a different encoding and coercion policy
# with respect to PEP 538 and PEP 540.
out, err = run_gdb(
'--eval-command',
'python import locale; print(locale.getpreferredencoding())')

encoding = out.rstrip()
if err or not encoding:
raise RuntimeError(
f'unable to determine the preferred encoding '
f'of embedded Python in GDB: {err}')

def check_repr(text):
try:
text.encode(encoding)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``test_gdb.test_strings()`` when ``LC_ALL=C`` and GDB was compiled with
Python 3.6 or earlier.