This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/22481] New: Python Exception <class 'gdb.error'> Trying to read string with inappropriate type `int'.:
- From: "hi-angel at yandex dot ru" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 23 Nov 2017 11:54:45 +0000
- Subject: [Bug gdb/22481] New: Python Exception <class 'gdb.error'> Trying to read string with inappropriate type `int'.:
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=22481
Bug ID: 22481
Summary: Python Exception <class 'gdb.error'> Trying to read
string with inappropriate type `int'.:
Product: gdb
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: hi-angel at yandex dot ru
Target Milestone: ---
#Steps to reproduce:
1. Write the following code to ~/gdb.py
class my_print:
def __init__(self, val):
self.val = val
def to_string(self):
return self.val.string()
def lookup_type_my_int (val):
if str(val.type) == 'int':
return my_print(val)
return None
gdb.pretty_printers.append(lookup_type_my_int)
2. Run `gdb -nh`
3. type `source ~/gdb.py`
4. type `print 1`
Expected result: the value of "val" is printed
Actual results: error "$1 = Python Exception <class 'gdb.error'> Trying to read
string with inappropriate type `int'.:".
#Additional info:
python version 3.6.3
Some more results because this issue might be useful for someone coming from
google in attempt to use pretty printers:
Using "return str(self.val)" results in "$1 = Python Exception <class
'RecursionError'> maximum recursion depth exceeded in comparison:
1"
And using simply "return self.val" results in "[1] 29554 segmentation fault
(core dumped) gdb -q -nh"
--
You are receiving this mail because:
You are on the CC list for the bug.