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
3bba77a2
Commit
3bba77a2
authored
May 08, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhance refnanny a bit to raise less errors on shutdown and report better positions in those cases.
parent
f4d5dec3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
Cython/Runtime/refnanny.pyx
Cython/Runtime/refnanny.pyx
+14
-6
No files found.
Cython/Runtime/refnanny.pyx
View file @
3bba77a2
...
...
@@ -10,6 +10,9 @@ loglevel = 0
reflog
=
[]
cdef
log
(
level
,
action
,
obj
,
lineno
):
if
reflog
is
None
:
# can happen during finalisation
return
if
loglevel
>=
level
:
reflog
.
append
((
lineno
,
action
,
id
(
obj
)))
...
...
@@ -64,15 +67,17 @@ cdef class Context(object):
self
.
errors
.
append
(
msg
)
return
u"
\
n
"
.
join
([
f'REFNANNY:
{
error
}
'
for
error
in
self
.
errors
])
if
self
.
errors
else
None
cdef
void
report_unraisable
(
object
e
=
None
):
cdef
void
report_unraisable
(
filename
,
int
lineno
,
object
e
=
None
):
try
:
if
e
is
None
:
import
sys
e
=
sys
.
exc_info
()[
1
]
print
(
f"refnanny raised an exception:
{
e
}
"
)
print
(
f"refnanny raised an exception
from
{
filename
}
:
{
lineno
}
:
{
e
}
"
)
finally
:
return
# 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.
...
...
@@ -91,7 +96,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N
Py_INCREF
(
ctx
)
result
=
<
PyObject
*>
ctx
except
Exception
,
e
:
report_unraisable
(
e
)
report_unraisable
(
filename
,
lineno
,
e
)
PyErr_Restore
(
type
,
value
,
tb
)
return
result
...
...
@@ -106,7 +111,7 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
is_null
=
p_obj
is
NULL
,
)
except
:
report_unraisable
()
report_unraisable
(
(
<
Context
>
ctx
).
filename
,
lineno
=
(
<
Context
>
ctx
).
start
)
finally
:
PyErr_Restore
(
type
,
value
,
tb
)
return
# swallow any exceptions
...
...
@@ -123,7 +128,7 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
is_null
=
p_obj
is
NULL
,
)
except
:
report_unraisable
()
report_unraisable
(
(
<
Context
>
ctx
).
filename
,
lineno
=
(
<
Context
>
ctx
).
start
)
finally
:
PyErr_Restore
(
type
,
value
,
tb
)
return
decref_ok
# swallow any exceptions
...
...
@@ -156,7 +161,10 @@ cdef void FinishContext(PyObject** ctx):
print
(
errors
)
context
=
None
except
:
report_unraisable
()
report_unraisable
(
context
.
filename
if
context
is
not
None
else
None
,
lineno
=
context
.
start
if
context
is
not
None
else
0
,
)
finally
:
Py_CLEAR
(
ctx
[
0
])
PyErr_Restore
(
type
,
value
,
tb
)
...
...
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