Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
fix unicode printing for python 2 and 3
Browse files Browse the repository at this point in the history
I had this error with GDB 8.3
(gdb) p str
$1 = Python Exception <class 'NameError'> name 'unichr' is not defined:

(gdb) py
>import sys
>print(sys.version)
>end
3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0]
(gdb)
  • Loading branch information
Macfly committed Dec 17, 2019
1 parent 9eb1bc3 commit 8c9ca03
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libcxx/v1/printers.py
Expand Up @@ -18,6 +18,7 @@
import re
import gdb
import sys
from builtins import chr

if sys.version_info[0] > 2:
# Python 3 stuff
Expand Down Expand Up @@ -148,7 +149,7 @@ def to_string(self):
len = sl['__size_']
ptr = sl['__data_']

return u''.join(unichr(ptr[i]) for i in range(len))
return u''.join(chr(ptr[i]) for i in range(len))

def display_hint(self):
return 'string'
Expand Down

0 comments on commit 8c9ca03

Please sign in to comment.