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
8b7e7c87
Commit
8b7e7c87
authored
Feb 21, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
22270037
38e665c4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
38 deletions
+45
-38
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-1
Cython/Runtime/refnanny.pyx
Cython/Runtime/refnanny.pyx
+44
-37
No files found.
Cython/Compiler/ModuleNode.py
View file @
8b7e7c87
...
...
@@ -2359,7 +2359,7 @@ static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
#define __Pyx_GIVEREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_SetupRefcountContext(name)
#define __Pyx_FinishRefcountContext()
0
#define __Pyx_FinishRefcountContext()
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) if((r) == NULL) ; else __Pyx_GIVEREF(r)
#define __Pyx_XGOTREF(r) if((r) == NULL) ; else __Pyx_GOTREF(r)
...
...
Cython/Runtime/refnanny.pyx
View file @
8b7e7c87
...
...
@@ -33,19 +33,23 @@ class Context(object):
linenumbers
.
append
(
lineno
)
def
delref
(
self
,
obj
,
lineno
,
is_null
):
# returns whether it is ok to do the decref operation
log
(
LOG_ALL
,
u'delref'
,
u"<NULL>"
if
is_null
else
obj
,
lineno
)
if
is_null
:
self
.
errors
.
append
(
u"NULL argument on line %d"
%
lineno
)
return
return
False
id_
=
id
(
obj
)
count
,
linenumbers
=
self
.
refs
.
get
(
id_
,
(
0
,
[]))
if
count
==
0
:
self
.
errors
.
append
(
u"Too many decrefs on line %d, reference acquired on lines %r"
%
(
lineno
,
linenumbers
))
return
False
elif
count
==
1
:
del
self
.
refs
[
id_
]
return
True
else
:
self
.
refs
[
id_
]
=
(
count
-
1
,
linenumbers
)
return
True
def
end
(
self
):
if
len
(
self
.
refs
)
>
0
:
...
...
@@ -58,21 +62,28 @@ class Context(object):
else
:
return
None
def
report_unraisable
(
e
):
try
:
print
"refnanny raised an exception: %s"
%
e
except
:
pass
# We absolutely cannot exit with an exception
# All Python operations must happen after any existing
# exception has been fetched, in case we are called from
# exception-handling code.
cdef
PyObject
*
NewContext
(
char
*
funcname
,
int
lineno
,
char
*
filename
)
except
NULL
:
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
cdef
PyObject
*
result
=
NULL
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
ctx
=
Context
(
funcname
,
lineno
,
filename
)
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
Py_INCREF
(
ctx
)
return
<
PyObject
*>
ctx
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
result
=
<
PyObject
*>
ctx
except
Exception
,
e
:
report_unraisable
(
e
)
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
return
result
cdef
void
GOTREF
(
PyObject
*
ctx
,
PyObject
*
p_obj
,
int
lineno
):
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
...
...
@@ -83,58 +94,54 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
(
<
object
>
ctx
).
regref
(
None
,
lineno
,
True
)
else
:
(
<
object
>
ctx
).
regref
(
<
object
>
p_obj
,
lineno
,
False
)
except
Exception
,
e
:
report_unraisable
(
e
)
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
cdef
void
GIVEREF
(
PyObject
*
ctx
,
PyObject
*
p_obj
,
int
lineno
):
cdef
int
GIVEREF_and_report
(
PyObject
*
ctx
,
PyObject
*
p_obj
,
int
lineno
):
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
if
ctx
==
NULL
:
return
cdef
bint
decref_ok
=
False
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
assert
ctx
is
not
NULL
,
"ctx us NULL"
if
p_obj
is
NULL
:
(
<
object
>
ctx
).
delref
(
None
,
lineno
,
True
)
decref_ok
=
(
<
object
>
ctx
).
delref
(
None
,
lineno
,
True
)
else
:
(
<
object
>
ctx
).
delref
(
<
object
>
p_obj
,
lineno
,
False
)
decref_ok
=
(
<
object
>
ctx
).
delref
(
<
object
>
p_obj
,
lineno
,
False
)
except
Exception
,
e
:
report_unraisable
(
e
)
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
raise
return
decref_ok
cdef
void
GIVEREF
(
PyObject
*
ctx
,
PyObject
*
p_obj
,
int
lineno
):
GIVEREF_and_report
(
ctx
,
p_obj
,
lineno
)
cdef
void
INCREF
(
PyObject
*
ctx
,
PyObject
*
obj
,
int
lineno
):
if
obj
is
not
NULL
:
Py_INCREF
(
<
object
>
obj
)
GOTREF
(
ctx
,
obj
,
lineno
)
cdef
void
DECREF
(
PyObject
*
ctx
,
PyObject
*
obj
,
int
lineno
):
# GIVEREF raises exception if we hit 0
GIVEREF
(
ctx
,
obj
,
lineno
)
if
GIVEREF_and_report
(
ctx
,
obj
,
lineno
):
if
obj
is
not
NULL
:
Py_DECREF
(
<
object
>
obj
)
cdef
void
FinishContext
(
PyObject
**
ctx
):
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
if
ctx
==
NULL
:
assert
False
if
ctx
[
0
]
==
NULL
:
assert
False
# XXX What to do here?
cdef
object
errors
=
None
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
if
ctx
==
NULL
:
assert
False
,
"ctx is NULL"
if
ctx
[
0
]
==
NULL
:
assert
False
,
"ctx[0] is NULL"
errors
=
(
<
object
>
ctx
[
0
]).
end
()
pos
=
(
<
object
>
ctx
[
0
]).
filename
,
(
<
object
>
ctx
[
0
]).
name
if
errors
:
print
u"%s: %s()"
%
pos
print
errors
# raise Error(errors)
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
except
:
Py_XDECREF
(
<
object
>
type
)
Py_XDECREF
(
<
object
>
value
)
Py_XDECREF
(
<
object
>
tb
)
finally
:
except
Exception
,
e
:
report_unraisable
(
e
)
Py_XDECREF
(
<
object
>
ctx
[
0
])
ctx
[
0
]
=
NULL
PyErr_Restore
(
<
object
>
type
,
<
object
>
value
,
<
object
>
tb
)
cdef
extern
from
"Python.h"
:
object
PyCObject_FromVoidPtr
(
void
*
,
void
(
*
)(
void
*
))
...
...
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