Discussion:
[Bug python/16047] New: python docs say printer .to_string is optional, but it is required
b.r.longbons at gmail dot com
2013-10-14 20:34:50 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=16047

Bug ID: 16047
Summary: python docs say printer .to_string is optional, but it
is required
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: b.r.longbons at gmail dot com

The documentation of the GDB pretty printer API [1] says that the .to_string
method is called "if the to_string method exists". This would be useful if the
object only has synthetic children.

But the actual result is:

Python Exception <type 'exceptions.AttributeError'> 'ZString' object has no
attribute 'to_string':

[1]
https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html#index-pretty_005fprinter_002eto_005fstring-1860
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-08 19:48:26 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=16047

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Seems like an oversight in the CLI layer. varobj seems to get it right.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-08 20:38:58 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=16047

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-09-09 02:51:49 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=16047

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=332cf4c9251a31f0addc2ce2970c9a8bb0c16f96

commit 332cf4c9251a31f0addc2ce2970c9a8bb0c16f96
Author: Tom Tromey <***@tromey.com>
Date: Sat Sep 8 14:40:38 2018 -0600

Allow a pretty-printer without a to_string method

PR python/16047 points out that, while the documentation says that the
to_string method is optional for a pretty-printer, the code disagrees
and throws an exception. This patch fixes the problem. varobj is
already ok here.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-09-08 Tom Tromey <***@tromey.com>

PR python/16047:
* python/py-prettyprint.c (pretty_print_one_value): Check for
to_string method.

gdb/testsuite/ChangeLog
2018-09-08 Tom Tromey <***@tromey.com>

PR python/16047:
* gdb.python/py-prettyprint.py (pp_int_typedef3): New class.
(register_pretty_printers): Register new printer.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add int_type3
test.
* gdb.python/py-prettyprint.c (int_type3): New typedef.
(an_int_type3): New global.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-08 21:28:56 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=16047

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |8.3

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...