classification
Title: test_gdb fails with Posix locale in 3.7
Type: behavior Stage:
Components: Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2018-02-12 19:43 by serhiy.storchaka, last changed 2018-02-13 02:33 by ncoghlan.

Messages (2)
msg312069 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-12 19:43
$ LC_ALL=C ./python -We -m test -vuall -m test_strings test_gdb
...
======================================================================
FAIL: test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode strings
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython3.7/Lib/test/test_gdb.py", line 331, in test_strings
    check_repr('\u2620')
  File "/home/serhiy/py/cpython3.7/Lib/test/test_gdb.py", line 323, in check_repr
    self.assertGdbRepr(text)
  File "/home/serhiy/py/cpython3.7/Lib/test/test_gdb.py", line 271, in assertGdbRepr
    % (gdb_repr, exp_repr, gdb_output)))
AssertionError: "'\\u2620'" != "'☠'"
- '\u2620'
+ '☠'
 : "'\\u2620'" did not equal expected "'☠'"; full output was:
Breakpoint 1 at 0x11a4df: file Python/bltinmodule.c, line 1215.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, builtin_id (self=self@entry=, v='\u2620') at Python/bltinmodule.c:1215
1215    {
#0  builtin_id (self=, v='\u2620') at Python/bltinmodule.c:1215


----------------------------------------------------------------------

This looks be related to PEP 538.
msg312095 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-02-13 02:33
I can reproduce this, but it looks to me like it's being triggered by UTF-8 mode rather than locale coercion (the "LC_ALL=C" setting will implicitly disable locale coercion entirely):

```
$ LANG=C PYTHONCOERCECLOCALE=warn ./python -We -m test -uall -m test_strings test_gdb
Python detected LC_CTYPE=C: LC_CTYPE coerced to C.UTF-8 (set another locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).
Run tests sequentially
0:00:00 load avg: 0.34 [1/1] test_gdb
1 test OK.

Total duration: 2 sec
Tests result: SUCCESS

$ LC_ALL=C PYTHONUTF8=0 ./python -We -m test -uall -m test_strings test_gdb
Run tests sequentially
0:00:00 load avg: 0.17 [1/1] test_gdb
1 test OK.

Total duration: 2 sec
Tests result: SUCCESS
```

I expect the fix will be to adjust test_gdb's expectations in this case,  as there's going to be a genuine difference between gdb's locale dependent behaviour and Python's UTF-8 mode behaviour.
History
Date User Action Args
2018-02-13 02:33:33ncoghlansetnosy: + vstinner
messages: + msg312095
2018-02-12 19:43:13serhiy.storchakacreate