summaryrefslogtreecommitdiff
path: root/Cython/Debugger/libpython.py
diff options
context:
space:
mode:
authorMark Florisson <markflorisson88@gmail.com>2010-11-16 12:58:49 +0100
committerMark Florisson <markflorisson88@gmail.com>2010-11-16 12:58:49 +0100
commit415e7ea3c142ae14fef4aebdf0b73b5a92d79e2a (patch)
tree166acce442f4c5322f0ab0daedfdfb8966655e34 /Cython/Debugger/libpython.py
parent814c63769f143f608fa62da5c0954228d116e8f2 (diff)
downloadcython-415e7ea3c142ae14fef4aebdf0b73b5a92d79e2a.tar.gz
Ensure 'cy locals' and 'cy exec' don't use uninitialized local variables (which fixes a lot of 'cy exec' core dumps! :)
Diffstat (limited to 'Cython/Debugger/libpython.py')
-rw-r--r--Cython/Debugger/libpython.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py
index 45e1fde25..64f2eb2f3 100644
--- a/Cython/Debugger/libpython.py
+++ b/Cython/Debugger/libpython.py
@@ -1929,7 +1929,7 @@ class PythonCodeExecutor(object):
pointer = pointervalue(chunk)
if pointer == 0:
- err("No memory could be allocated in the inferior.")
+ raise gdb.GdbError("No memory could be allocated in the inferior.")
return pointer
@@ -1950,7 +1950,7 @@ class PythonCodeExecutor(object):
pointer = pointervalue(result)
if pointer == 0:
- err("Unable to allocate Python string in "
+ raise gdb.GdbError("Unable to allocate Python string in "
"the inferior.")
return pointer
@@ -1958,6 +1958,10 @@ class PythonCodeExecutor(object):
def free(self, pointer):
gdb.parse_and_eval("free((void *) %d)" % pointer)
+ def incref(self, pointer):
+ "Increment the reference count of a Python object in the inferior."
+ gdb.parse_and_eval('Py_IncRef((PyObject *) %d)' % pointer)
+
def decref(self, pointer):
"Decrement the reference count of a Python object in the inferior."
# Py_DecRef is like Py_XDECREF, but a function. So we don't have
@@ -1975,7 +1979,7 @@ class PythonCodeExecutor(object):
leave the debuggee in an unsafe state or terminate it alltogether.
"""
if '\0' in code:
- err("String contains NUL byte.")
+ raise gdb.GdbError("String contains NUL byte.")
code += '\0'