public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: [python] python-utils.c (python_string_to_unicode): Always return a new reference.
@ 2009-02-26 8:45 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2009-02-26 8:45 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via b5235efef9aa1d619d8a5defc5aa1219dff76d3d (commit)
from 9f534e722211caffa7caef5cd11c5da2ac24f6c4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit b5235efef9aa1d619d8a5defc5aa1219dff76d3d
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Thu Feb 26 08:44:03 2009 +0000
[python] python-utils.c (python_string_to_unicode): Always return a new reference.
2009-02-26 Phil Muldoon <pmuldoon@redhat.com>
* python/python-utils.c (python_string_to_unicode): Always return
a new reference.
(python_string_to_target_string): Decrement transient python
instance.
(python_string_to_host_string): Likewise.
-----------------------------------------------------------------------
Summary of changes:
gdb/python/python-utils.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
First 500 lines of diff:
diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c
index c6c305f..f9c9486 100644
--- a/gdb/python/python-utils.c
+++ b/gdb/python/python-utils.c
@@ -82,7 +82,11 @@ python_string_to_unicode (PyObject *obj)
/* If obj is already a unicode string, just return it.
I wish life was always that simple... */
if (PyUnicode_Check (obj))
- unicode_str = obj;
+ {
+ unicode_str = obj;
+ Py_INCREF (obj);
+ }
+
else if (PyString_Check (obj))
unicode_str = PyUnicode_FromEncodedObject (obj, host_charset (), NULL);
else
@@ -137,12 +141,15 @@ char *
python_string_to_target_string (PyObject *obj)
{
PyObject *str;
+ char *result;
str = python_string_to_unicode (obj);
if (str == NULL)
return NULL;
- return unicode_to_target_string (str);
+ result = unicode_to_target_string (str);
+ Py_DECREF (str);
+ return result;
}
/* Converts a python string (8-bit or unicode) to a target string in
@@ -153,12 +160,15 @@ char *
python_string_to_host_string (PyObject *obj)
{
PyObject *str;
+ char *result;
str = python_string_to_unicode (obj);
if (str == NULL)
return NULL;
- return unicode_to_encoded_string (str, host_charset ());
+ result = unicode_to_encoded_string (str, host_charset ());
+ Py_DECREF (str);
+ return result;
}
/* Converts a target string of LENGTH bytes in the target's charset to a
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-26 8:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-26 8:45 [SCM] archer-tromey-python: [python] python-utils.c (python_string_to_unicode): Always return a new reference pmuldoon
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).