From 984ee559a26e138d8bcc1f850c1cacb9eded2b1c Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 26 Apr 2018 16:51:40 -0600 Subject: Fix "set" handling of Python parameters It's long bothered me that setting a Python parameter from the CLI will print the "set" help text by default. I think usually "set" commands should be silent. And, while you can modify this behavior a bit by providing a "get_set_string" method, if this method returns an empty string, a blank line will be printed. This patch removes the "help" behavior and changes the get_set_string behavior to avoid printing a blank line. The code has a comment about preserving API behavior, but I don't think this is truly important; and in any case the workaround -- implementing get_set_string -- is trivial. Regression tested on x86-64 Fedora 26. 2018-04-26 Tom Tromey * NEWS: Mention new "set" behavior. * python/py-param.c (get_set_value): Don't print an empty string. Don't call get_doc_string. gdb/doc/ChangeLog 2018-04-26 Tom Tromey * python.texi (Parameters In Python): Update get_set_string documentation. --- gdb/doc/python.texi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'gdb/doc/python.texi') diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 60e016a..584b909 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -3748,14 +3748,16 @@ parameter. It can be read and assigned to just as any other attribute. @value{GDBN} does validation when assignments are made. @end defvar -There are two methods that should be implemented in any -@code{Parameter} class. These are: +There are two methods that may be implemented in any @code{Parameter} +class. These are: @defun Parameter.get_set_string (self) -@value{GDBN} will call this method when a @var{parameter}'s value has -been changed via the @code{set} API (for example, @kbd{set foo off}). -The @code{value} attribute has already been populated with the new -value and may be used in output. This method must return a string. +If this method exists, @value{GDBN} will call it when a +@var{parameter}'s value has been changed via the @code{set} API (for +example, @kbd{set foo off}). The @code{value} attribute has already +been populated with the new value and may be used in output. This +method must return a string. If the returned string is not empty, +@value{GDBN} will present it to the user. @end defun @defun Parameter.get_show_string (self, svalue) -- cgit v1.1