diff options
author | Elvis Pranskevichus <elvis@magic.io> | 2018-09-22 01:13:16 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-09-22 01:13:16 (GMT) |
commit | 7279b5125e7c5d84a473d250b27d353cb7f6628e (patch) | |
tree | 7efa3a9e937f033c1dc3e3a06e7be5006d29ba39 /Lib/test/test_gdb.py | |
parent | d64ee1a5ba2007ae5fe085dd3495013d940a51bb (diff) | |
download | cpython-7279b5125e7c5d84a473d250b27d353cb7f6628e.zip cpython-7279b5125e7c5d84a473d250b27d353cb7f6628e.tar.gz cpython-7279b5125e7c5d84a473d250b27d353cb7f6628e.tar.bz2 |
bpo-34537: Fix test_gdb:test_strings with LC_ALL=C (GH-9483)
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.
Thanks to Victor Stinner for a hint on how to fix this.
Diffstat (limited to 'Lib/test/test_gdb.py')
-rw-r--r-- | Lib/test/test_gdb.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index c2ca57a..93a2c7d 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -321,7 +321,20 @@ class PrettyPrintTests(DebuggerTests): 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) |