This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_gdb: test_strings() fails with ASCII locale
Type: Stage:
Components: Tests, Unicode Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dmalcolm, loewis, vstinner
Priority: normal Keywords: patch

Created on 2010-04-28 13:58 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_gdb_unicode-2.patch vstinner, 2010-04-30 01:01
Messages (5)
msg104431 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-28 13:58
http://www.python.org/dev/buildbot/builders/alpha Debian 3.x/builds/67/steps/test/logs/stdio

======================================================================
ERROR: test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode strings
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/test/test_gdb.py", line 230, in test_strings
    self.assertGdbRepr('\u2620')
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/test/test_gdb.py", line 176, in assertGdbRepr
    cmds_after_breakpoint)
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/test/test_gdb.py", line 144, in get_gdb_repr
    import_site=import_site)
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/test/test_gdb.py", line 120, in get_stack_trace
    out, err = self.run_gdb(*args)
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/test/test_gdb.py", line 60, in run_gdb
    args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/subprocess.py", line 670, in __init__
    restore_signals, start_new_session)
  File "/home/doko/buildarea/3.x.klose-debian-alpha/build/Lib/subprocess.py", line 1115, in _execute_child
    restore_signals, start_new_session, preexec_fn)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2620' in position 4: ordinal not in range(128)

You can try with: "LANG= ./python Lib/test/regrtest.py test_gdb".

We should skip the test if '\u2620' is not encodable to sys.getfileystemencoding(), or maybe use '\\u2620'.
msg104604 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-30 00:54
Patch using raw string instead of the unicode character directly to avoid the locale issue. I'm not sure that we really test unicode support of the gdb library using my patch.

I also get another error: << AssertionError: "'\\\\U0001D121'" did not equal expected "'\\U0000d834\\U0000dd21'" >>. The problem is that test_gdb tests sys.maxunicode whereas gdb may use a different Python library (eg. Python2 whereas we are using Python3) not using the same unicode option (narrow vs wide unicode). The test should ask gdb for its sys.maxunicode value.
msg104605 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-30 01:01
> The test should ask gdb for its sys.maxunicode value.

Ok, done in a new version of the patch.

test_gdb now pass with and without locale (utf8 and ascii).

The patch is for py3k. test_gdb in Python trunk doesn't test has the unicode tests in test_strings() function.
msg106115 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-05-19 23:05
r81375 improves unicode support of libpython.py. I hope that it will be enough to fix test_strings() failures.
msg106138 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-05-20 11:33
> r81375 improves unicode support of libpython.py. I hope that it will be
> enough to fix test_strings() failures.

Ok, buildbots seem happy: "alpha Debian 3.x" is green again.

Python 3.1 doesn't have libpython.py: commit blocked (r81376).

I forward ported some code from py3k to trunk to fix support of non-BMP unicode characters: r81377. Commit blocked in py3k (r81378) and 2.6 (r81379).
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52805
2010-05-20 11:33:15vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg106138
2010-05-19 23:05:36vstinnersetmessages: + msg106115
2010-04-30 01:01:08vstinnersetfiles: - test_gdb_unicode.patch
2010-04-30 01:01:01vstinnersetfiles: + test_gdb_unicode-2.patch

messages: + msg104605
2010-04-30 00:54:43vstinnersetfiles: + test_gdb_unicode.patch
keywords: + patch
messages: + msg104604
2010-04-28 13:58:58vstinnercreate