Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
1fdb965c
Commit
1fdb965c
authored
Jan 30, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refnanny fixes; it now runs the test suite correctly.
parent
f4e29a0b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
10 deletions
+38
-10
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+2
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-2
Cython/Runtime/refnanny.pyx
Cython/Runtime/refnanny.pyx
+23
-6
No files found.
Cython/Compiler/Buffer.py
View file @
1fdb965c
...
@@ -305,7 +305,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
...
@@ -305,7 +305,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
for
i
in
range
(
3
)]
for
i
in
range
(
3
)]
code
.
putln
(
'PyErr_Fetch(&%s, &%s, &%s);'
%
(
type
,
value
,
tb
))
code
.
putln
(
'PyErr_Fetch(&%s, &%s, &%s);'
%
(
type
,
value
,
tb
))
code
.
putln
(
'if (%s) {'
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
lhs_cname
)))
code
.
putln
(
'if (%s) {'
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
lhs_cname
)))
code
.
putln
(
'Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);'
%
(
type
,
value
,
tb
))
code
.
putln
(
'Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);'
%
(
type
,
value
,
tb
))
# Do not refnanny these!
code
.
globalstate
.
use_utility_code
(
raise_buffer_fallback_code
)
code
.
globalstate
.
use_utility_code
(
raise_buffer_fallback_code
)
code
.
putln
(
'__Pyx_RaiseBufferFallbackError();'
)
code
.
putln
(
'__Pyx_RaiseBufferFallbackError();'
)
code
.
putln
(
'} else {'
)
code
.
putln
(
'} else {'
)
...
@@ -323,7 +323,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
...
@@ -323,7 +323,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
# In this case, auxiliary vars should be set up right in initialization to a zero-buffer,
# In this case, auxiliary vars should be set up right in initialization to a zero-buffer,
# so it suffices to set the buf field to NULL.
# so it suffices to set the buf field to NULL.
code
.
putln
(
'if (%s) {'
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
rhs_cname
)))
code
.
putln
(
'if (%s) {'
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
rhs_cname
)))
code
.
putln
(
'%s = %s;
Py
_INCREF(Py_None); %s.buf = NULL;'
%
code
.
putln
(
'%s = %s;
__Pyx
_INCREF(Py_None); %s.buf = NULL;'
%
(
lhs_cname
,
(
lhs_cname
,
PyrexTypes
.
typecast
(
buffer_type
,
PyrexTypes
.
py_object_type
,
"Py_None"
),
PyrexTypes
.
typecast
(
buffer_type
,
PyrexTypes
.
py_object_type
,
"Py_None"
),
bufstruct
))
bufstruct
))
...
...
Cython/Compiler/ExprNodes.py
View file @
1fdb965c
...
@@ -1878,10 +1878,12 @@ class IndexNode(ExprNode):
...
@@ -1878,10 +1878,12 @@ class IndexNode(ExprNode):
ptr
=
code
.
funcstate
.
allocate_temp
(
self
.
buffer_type
.
buffer_ptr_type
,
manage_ref
=
False
)
ptr
=
code
.
funcstate
.
allocate_temp
(
self
.
buffer_type
.
buffer_ptr_type
,
manage_ref
=
False
)
rhs_code
=
rhs
.
result
()
rhs_code
=
rhs
.
result
()
code
.
putln
(
"%s = %s;"
%
(
ptr
,
ptrexpr
))
code
.
putln
(
"%s = %s;"
%
(
ptr
,
ptrexpr
))
code
.
put_gotref
(
"*%s"
%
ptr
)
code
.
putln
(
"__Pyx_DECREF(*%s); __Pyx_INCREF(%s);"
%
(
code
.
putln
(
"__Pyx_DECREF(*%s); __Pyx_INCREF(%s);"
%
(
ptr
,
rhs_code
ptr
,
rhs_code
))
))
code
.
putln
(
"*%s %s= %s;"
%
(
ptr
,
op
,
rhs_code
))
code
.
putln
(
"*%s %s= %s;"
%
(
ptr
,
op
,
rhs_code
))
code
.
put_giveref
(
"*%s"
%
ptr
)
code
.
funcstate
.
release_temp
(
ptr
)
code
.
funcstate
.
release_temp
(
ptr
)
else
:
else
:
# Simple case
# Simple case
...
@@ -2887,6 +2889,7 @@ class AttributeNode(NewTempExprNode):
...
@@ -2887,6 +2889,7 @@ class AttributeNode(NewTempExprNode):
if
self
.
type
.
is_pyobject
:
if
self
.
type
.
is_pyobject
:
rhs
.
make_owned_reference
(
code
)
rhs
.
make_owned_reference
(
code
)
code
.
put_giveref
(
rhs
.
py_result
())
code
.
put_giveref
(
rhs
.
py_result
())
code
.
put_gotref
(
select_code
)
code
.
put_decref
(
select_code
,
self
.
ctype
())
code
.
put_decref
(
select_code
,
self
.
ctype
())
code
.
putln
(
code
.
putln
(
"%s = %s;"
%
(
"%s = %s;"
%
(
...
@@ -3354,6 +3357,7 @@ class SetNode(NewTempExprNode):
...
@@ -3354,6 +3357,7 @@ class SetNode(NewTempExprNode):
"%s = PySet_New(0); %s"
%
(
"%s = PySet_New(0); %s"
%
(
self
.
result
(),
self
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
arg
.
generate_evaluation_code
(
code
)
arg
.
generate_evaluation_code
(
code
)
code
.
putln
(
code
.
putln
(
...
...
Cython/Compiler/Nodes.py
View file @
1fdb965c
...
@@ -1254,16 +1254,20 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1254,16 +1254,20 @@ class FuncDefNode(StatNode, BlockNode):
# the following line should be removed when this bug is fixed.
# the following line should be removed when this bug is fixed.
code
.
putln
(
"if (%s == NULL) return 0;"
%
info
)
code
.
putln
(
"if (%s == NULL) return 0;"
%
info
)
code
.
putln
(
"%s->obj = Py_None; __Pyx_INCREF(Py_None);"
%
info
)
code
.
putln
(
"%s->obj = Py_None; __Pyx_INCREF(Py_None);"
%
info
)
code
.
put_giveref
(
"%s->obj"
%
info
)
# Do not refnanny object within structs
def
getbuffer_error_cleanup
(
self
,
code
):
def
getbuffer_error_cleanup
(
self
,
code
):
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
code
.
put_gotref
(
"%s->obj"
%
info
)
code
.
putln
(
"__Pyx_DECREF(%s->obj); %s->obj = NULL;"
%
code
.
putln
(
"__Pyx_DECREF(%s->obj); %s->obj = NULL;"
%
(
info
,
info
))
(
info
,
info
))
def
getbuffer_normal_cleanup
(
self
,
code
):
def
getbuffer_normal_cleanup
(
self
,
code
):
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
code
.
putln
(
"if (%s->obj == Py_None) { __Pyx_DECREF(Py_None); %s->obj = NULL; }"
%
code
.
putln
(
"if (%s->obj == Py_None) {"
%
info
)
(
info
,
info
))
code
.
put_gotref
(
"Py_None"
)
code
.
putln
(
"__Pyx_DECREF(Py_None); %s->obj = NULL;"
%
info
)
code
.
putln
(
"}"
)
class
CFuncDefNode
(
FuncDefNode
):
class
CFuncDefNode
(
FuncDefNode
):
# C function definition.
# C function definition.
...
@@ -2014,6 +2018,8 @@ class DefNode(FuncDefNode):
...
@@ -2014,6 +2018,8 @@ class DefNode(FuncDefNode):
code
.
putln
(
"if (unlikely(!%s)) return %s;"
%
(
code
.
putln
(
"if (unlikely(!%s)) return %s;"
%
(
self
.
starstar_arg
.
entry
.
cname
,
self
.
error_value
()))
self
.
starstar_arg
.
entry
.
cname
,
self
.
error_value
()))
self
.
starstar_arg
.
entry
.
xdecref_cleanup
=
0
self
.
starstar_arg
.
entry
.
xdecref_cleanup
=
0
code
.
put_gotref
(
self
.
starstar_arg
.
entry
.
cname
)
if
self
.
star_arg
:
if
self
.
star_arg
:
code
.
put_incref
(
Naming
.
args_cname
,
py_object_type
)
code
.
put_incref
(
Naming
.
args_cname
,
py_object_type
)
...
@@ -3234,6 +3240,7 @@ class ExecStatNode(StatNode):
...
@@ -3234,6 +3240,7 @@ class ExecStatNode(StatNode):
arg
.
free_temps
(
code
)
arg
.
free_temps
(
code
)
code
.
putln
(
code
.
putln
(
code
.
error_goto_if_null
(
self
.
temp_result
,
self
.
pos
))
code
.
error_goto_if_null
(
self
.
temp_result
,
self
.
pos
))
code
.
put_gotref
(
self
.
temp_result
)
code
.
put_decref_clear
(
self
.
temp_result
,
py_object_type
)
code
.
put_decref_clear
(
self
.
temp_result
,
py_object_type
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
...
...
Cython/Runtime/refnanny.pyx
View file @
1fdb965c
...
@@ -60,15 +60,27 @@ cdef public void __Pyx_Refnanny_GOTREF(void* ctx, object obj, int lineno):
...
@@ -60,15 +60,27 @@ cdef public void __Pyx_Refnanny_GOTREF(void* ctx, object obj, int lineno):
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
if
ctx
==
NULL
:
return
if
ctx
==
NULL
:
return
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
(
<
object
>
ctx
).
regref
(
obj
,
lineno
)
(
<
object
>
ctx
).
regref
(
obj
,
lineno
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
cdef
public
void
__Pyx_Refnanny_GIVEREF
(
void
*
ctx
,
object
obj
,
int
lineno
):
cdef
public
void
__Pyx_Refnanny_GIVEREF
(
void
*
ctx
,
object
obj
,
int
lineno
):
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
if
ctx
==
NULL
:
return
if
ctx
==
NULL
:
return
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
(
<
object
>
ctx
).
delref
(
obj
,
lineno
)
(
<
object
>
ctx
).
delref
(
obj
,
lineno
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
cdef
public
void
__Pyx_Refnanny_INCREF
(
void
*
ctx
,
object
obj
,
int
lineno
):
cdef
public
void
__Pyx_Refnanny_INCREF
(
void
*
ctx
,
object
obj
,
int
lineno
):
Py_INCREF
(
obj
)
Py_INCREF
(
obj
)
...
@@ -88,9 +100,14 @@ cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1:
...
@@ -88,9 +100,14 @@ cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1:
obj
=
<
object
>
ctx
obj
=
<
object
>
ctx
try
:
try
:
obj
.
end
()
obj
.
end
()
finally
:
Py_DECREF
(
obj
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
exc
.
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
Exception
,
e
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
finally
:
Py_XDECREF
(
obj
)
return
0
return
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment