Commit fcac9282 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

refnanny: Disable in nogil functions

parent f4e84e98
...@@ -1068,7 +1068,8 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1068,7 +1068,8 @@ class FuncDefNode(StatNode, BlockNode):
# ----- Automatic lead-ins for certain special functions # ----- Automatic lead-ins for certain special functions
if is_getbuffer_slot: if is_getbuffer_slot:
self.getbuffer_init(code) self.getbuffer_init(code)
code.put_setup_refcount_context(self.entry.name) if not lenv.nogil:
code.put_setup_refcount_context(self.entry.name)
# ----- Fetch arguments # ----- Fetch arguments
self.generate_argument_parsing_code(env, code) self.generate_argument_parsing_code(env, code)
# If an argument is assigned to in the body, we must # If an argument is assigned to in the body, we must
...@@ -1183,17 +1184,18 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1183,17 +1184,18 @@ class FuncDefNode(StatNode, BlockNode):
# code.putln("/* TODO: decref scope object */") # code.putln("/* TODO: decref scope object */")
# ----- Return # ----- Return
# This code is duplicated in ModuleNode.generate_module_init_func # This code is duplicated in ModuleNode.generate_module_init_func
default_retval = self.return_type.default_value if not lenv.nogil:
err_val = self.error_value() default_retval = self.return_type.default_value
if err_val is None and default_retval: err_val = self.error_value()
err_val = default_retval if err_val is None and default_retval:
if self.return_type.is_pyobject: err_val = default_retval
code.put_xgiveref(self.return_type.as_pyobject(Naming.retval_cname)) if self.return_type.is_pyobject:
code.put_xgiveref(self.return_type.as_pyobject(Naming.retval_cname))
code.put_finish_refcount_context(self.pos, code.put_finish_refcount_context(self.pos,
self.entry.qualified_name, self.entry.qualified_name,
Naming.retval_cname, Naming.retval_cname,
err_val) err_val)
if not self.return_type.is_void: if not self.return_type.is_void:
code.putln("return %s;" % Naming.retval_cname) code.putln("return %s;" % Naming.retval_cname)
......
# Temporary hacky script, should be replaced # Temporary hacky script, should be replaced
# with distutils-based solution. # with distutils-based solution.
PYTHONINC=/local/include/python2.5 #PYTHONINC=/local/include/python2.5
PYTHONINC=/usr/include/python2.5
python ../../cython.py refnanny.pyx python ../../cython.py refnanny.pyx
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall \ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall \
......
from python_ref cimport Py_INCREF, Py_DECREF from python_ref cimport Py_INCREF, Py_DECREF
cimport python_exc as exc
loglevel = 0 loglevel = 0
reflog = [] reflog = []
...@@ -69,6 +71,12 @@ cdef public void __Pyx_Refnanny_DECREF(void* ctx, object obj, int lineno): ...@@ -69,6 +71,12 @@ cdef public void __Pyx_Refnanny_DECREF(void* ctx, object obj, int lineno):
Py_DECREF(obj) Py_DECREF(obj)
cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1: cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1:
cdef exc.PyObject* type, *value, *tb
if exc.PyErr_Occurred():
exc.PyErr_Fetch(&type, &value, &tb)
Py_DECREF(<object>type); Py_DECREF(<object>value); Py_DECREF(<object>tb)
print "cleared!"
print (exc.PyErr_Occurred() == NULL)
obj = <object>ctx obj = <object>ctx
try: try:
obj.end() obj.end()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment