public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Thiago Jung Bauermann <bauerman@br.ibm.com>,
	Project Archer <archer@sourceware.org>
Subject: Re: [python][patch] Preserve string length, and embedded-nulls in pretty-print string emission.
Date: Mon, 15 Jun 2009 20:50:00 -0000	[thread overview]
Message-ID: <4A36B3EE.8020102@redhat.com> (raw)
In-Reply-To: <m3my8ed7ak.fsf@fleche.redhat.com>

On 06/11/2009 06:11 PM, Tom Tromey wrote:


Hi Tom

Thanks for the comments. Most are done, but I have some further 
questions with others.


> Phil>  +  int is_string = 0;
>
> Phil>  -	  if (gdbpy_is_string (result))
> Phil>  -	    output = python_string_to_host_string (result);
> Phil>  -	  else if (PyObject_TypeCheck (result,&value_object_type))
> Phil>  +	  is_string = gdbpy_is_string (result);
> Phil>  +	  if (! is_string)
>
> I think the previous code was clearer.  Don't introduce is_string,
> instead...
>    


Agreed, fixed.


> Phil>  +	      Py_DECREF (result);
>
> Set 'result = NULL' here.
>    


Likewise


> Phil>  +unicode_to_encoded_string (PyObject *unicode_str, const char *charset, int *size)
>
> [...]
>
> Phil>  +  str_size = PyString_Size (string) + 1;
> Phil>  +  result = xmemdup (PyString_AsString (string), str_size, str_size);
> Phil>  +  if (size != NULL)
> Phil>  +    *size = str_size;
>
> How about a variant of this function that just returns the
> intermediate 'string' PyObject?
>    

To avoid the use of an out-parameter? I can see the use of returning an 
encoded version of the the unicode PyObject string, but if you wanted 
that, why would you just not call:

PyUnicode_AsEncodedString directly? Wouldn't the following:

static PyObject*
unicode_to_encoded_string (PyObject *unicode_str, const char *charset)
{
return PyUnicode_AsEncodedString (unicode_str, charset, NULL);
}

Be the same equivalent? What would the purpose of a new variant achieve 
there?


> Phil>  +      output = python_string_to_target_string (py_str,&len);
> Phil>  +      if (output)
> Phil>  +	{
> Phil>  +	  struct cleanup *old = make_cleanup (xfree, output);
>
> Adding a new unicode_to_target_string variant (or
> python_string_to_target_string, or whatever is nicest) means you can
> avoid an allocation here.
>    


Similar to above, I'm not sure what you mean here. 
python_string_to_target_string does more than than the previous hunk 
comment, but eventually will have to be converted to char * to pass 
through the LA_PRINT_STRING that is directly below this code?



> Phil>  --- a/gdb/varobj.c
> Phil>  +	    Py_DECREF(py_str);
>
> Space before open paren.
>
>    

Fixed thanks!

Regards

Phil

  reply	other threads:[~2009-06-15 20:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-22 20:23 Phil Muldoon
2009-05-27 17:35 ` Tom Tromey
2009-05-27 18:24   ` Phil Muldoon
2009-05-27 20:22     ` Tom Tromey
2009-06-01 16:26       ` Phil Muldoon
2009-06-02  5:11         ` Thiago Jung Bauermann
2009-06-02 23:46           ` Tom Tromey
2009-06-08 10:31             ` Phil Muldoon
2009-06-11 17:12               ` Tom Tromey
2009-06-15 20:50                 ` Phil Muldoon [this message]
2009-06-16 12:44                   ` Phil Muldoon
2009-06-16 18:07                     ` Tom Tromey
2009-06-18 12:20                       ` Phil Muldoon
2009-06-18 20:17                         ` Tom Tromey
2009-06-18 20:21                         ` Tom Tromey
2009-06-23 14:37                           ` Phil Muldoon
2009-06-23 16:37                             ` Tom Tromey
2009-06-23 16:56                               ` Phil Muldoon
2009-06-02 15:38         ` Jonas Maebe
2009-06-02 20:48           ` Phil Muldoon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A36B3EE.8020102@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=archer@sourceware.org \
    --cc=bauerman@br.ibm.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).