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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
832da3bf
Commit
832da3bf
authored
Sep 20, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid some redundant calls to PyThreadState_GET() to reduce locking etc. during exception handling
parent
8782d92a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
68 deletions
+106
-68
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-6
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-2
Cython/Compiler/Naming.py
Cython/Compiler/Naming.py
+1
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+20
-8
Cython/Utility/Builtins.c
Cython/Utility/Builtins.c
+1
-2
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+9
-10
Cython/Utility/Exceptions.c
Cython/Utility/Exceptions.c
+63
-24
Cython/Utility/FunctionArguments.c
Cython/Utility/FunctionArguments.c
+1
-2
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+7
-13
Cython/Utility/Profile.c
Cython/Utility/Profile.c
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
832da3bf
...
...
@@ -2253,11 +2253,9 @@ class NameNode(AtomicExprNode):
key_error_code
=
(
'{ PyErr_Clear(); PyErr_Format(PyExc_NameError, "name
\
'
%%s
\
'
is not defined", "%s"); }'
%
self
.
entry
.
name
)
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyErrExceptionMatches"
,
"Exceptions.c"
))
code
.
putln
(
'if (unlikely(PyObject_DelItem(%s, %s) < 0)) {'
' if (likely(
__Pyx_
PyErr_ExceptionMatches(PyExc_KeyError))) %s'
' if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) %s'
' %s '
'}'
%
(
namespace
,
interned_cname
,
key_error_code
,
...
...
@@ -2269,11 +2267,9 @@ class NameNode(AtomicExprNode):
del_code
=
'__Pyx_PyObject_DelAttrStr(%s, %s)'
%
(
Naming
.
module_cname
,
interned_cname
)
if
ignore_nonexisting
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyErrExceptionMatches"
,
"Exceptions.c"
))
code
.
putln
(
'if (unlikely(%s < 0)) {'
' if (likely(
__Pyx_
PyErr_ExceptionMatches(PyExc_AttributeError))) PyErr_Clear(); else %s '
' if (likely(PyErr_ExceptionMatches(PyExc_AttributeError))) PyErr_Clear(); else %s '
'}'
%
(
del_code
,
code
.
error_goto
(
self
.
pos
)))
else
:
code
.
put_error_if_neg
(
self
.
pos
,
del_code
)
...
...
Cython/Compiler/ModuleNode.py
View file @
832da3bf
...
...
@@ -1725,9 +1725,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyObject *v = PyObject_GenericGetAttr(o, n);"
)
if
getattr_entry
is
not
None
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyErrExceptionMatches"
,
"Exceptions.c"
))
code
.
putln
(
"if (!v &&
__Pyx_
PyErr_ExceptionMatches(PyExc_AttributeError)) {"
)
"if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {"
)
code
.
putln
(
"PyErr_Clear();"
)
code
.
putln
(
...
...
Cython/Compiler/Naming.py
View file @
832da3bf
...
...
@@ -82,6 +82,7 @@ kwds_cname = pyrex_prefix + "kwds"
lineno_cname
=
pyrex_prefix
+
"lineno"
clineno_cname
=
pyrex_prefix
+
"clineno"
cfilenm_cname
=
pyrex_prefix
+
"cfilenm"
local_tstate_cname
=
pyrex_prefix
+
"tstate"
module_cname
=
pyrex_prefix
+
"m"
moddoc_cname
=
pyrex_prefix
+
"mdoc"
methtable_cname
=
pyrex_prefix
+
"methods"
...
...
Cython/Compiler/Nodes.py
View file @
832da3bf
...
...
@@ -4122,8 +4122,7 @@ class GeneratorBodyDefNode(DefNode):
if
Future
.
generator_stop
in
env
.
global_scope
().
context
.
future_directives
:
# PEP 479: turn accidental StopIteration exceptions into a RuntimeError
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"pep479"
,
"Coroutine.c"
))
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyErrExceptionMatches"
,
"Exceptions.c"
))
code
.
putln
(
"if (unlikely(__Pyx_PyErr_ExceptionMatches(PyExc_StopIteration))) "
code
.
putln
(
"if (unlikely(PyErr_ExceptionMatches(PyExc_StopIteration))) "
"__Pyx_Generator_Replace_StopIteration();"
)
for
cname
,
type
in
code
.
funcstate
.
all_managed_temps
():
code
.
put_xdecref
(
cname
,
type
)
...
...
@@ -6710,8 +6709,10 @@ class TryExceptStatNode(StatNode):
if
can_raise
:
# inject code before the try block to save away the exception state
code
.
globalstate
.
use_utility_code
(
reset_exception_utility_code
)
save_exc
.
putln
(
"__Pyx_ExceptionSave(%s);"
%
', '
.
join
([
'&%s'
%
var
for
var
in
exc_save_vars
]))
save_exc
.
putln
(
"__Pyx_PyThreadState_declare"
)
save_exc
.
putln
(
"__Pyx_PyThreadState_assign"
)
save_exc
.
putln
(
"__Pyx_ExceptionSave(%s);"
%
(
', '
.
join
([
'&%s'
%
var
for
var
in
exc_save_vars
])))
for
var
in
exc_save_vars
:
save_exc
.
put_xgotref
(
var
)
...
...
@@ -6747,6 +6748,7 @@ class TryExceptStatNode(StatNode):
code
.
put_xdecref_clear
(
var
,
py_object_type
)
code
.
put_goto
(
try_end_label
)
code
.
put_label
(
our_error_label
)
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
# re-assign in case a generator yielded
for
temp_name
,
temp_type
in
temps_to_clean_up
:
code
.
put_xdecref_clear
(
temp_name
,
temp_type
)
for
except_clause
in
self
.
except_clauses
:
...
...
@@ -6764,14 +6766,18 @@ class TryExceptStatNode(StatNode):
code
.
put_goto
(
try_end_label
)
code
.
put_label
(
exit_label
)
code
.
mark_pos
(
self
.
pos
,
trace
=
False
)
restore_saved_exception
()
if
can_raise
:
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
# re-assign in case a generator yielded
restore_saved_exception
()
code
.
put_goto
(
old_label
)
if
code
.
label_used
(
except_end_label
):
if
not
normal_case_terminates
and
not
code
.
label_used
(
try_end_label
):
code
.
put_goto
(
try_end_label
)
code
.
put_label
(
except_end_label
)
restore_saved_exception
()
if
can_raise
:
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
# re-assign in case a generator yielded
restore_saved_exception
()
if
code
.
label_used
(
try_end_label
):
code
.
put_label
(
try_end_label
)
code
.
putln
(
"}"
)
...
...
@@ -7043,6 +7049,7 @@ class TryFinallyStatNode(StatNode):
if
preserve_error
:
code
.
putln
(
'/*exception exit:*/{'
)
code
.
putln
(
"__Pyx_PyThreadState_declare"
)
if
self
.
is_try_finally_in_nogil
:
code
.
declare_gilstate
()
if
needs_success_cleanup
:
...
...
@@ -7139,6 +7146,7 @@ class TryFinallyStatNode(StatNode):
code
.
putln
(
' '
.
join
([
"%s = 0;"
]
*
len
(
exc_vars
))
%
exc_vars
)
if
self
.
is_try_finally_in_nogil
:
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
for
temp_name
,
type
in
temps_to_clean_up
:
code
.
put_xdecref_clear
(
temp_name
,
type
)
...
...
@@ -7169,6 +7177,7 @@ class TryFinallyStatNode(StatNode):
if
self
.
is_try_finally_in_nogil
:
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
# re-assign in case a generator yielded
# not using preprocessor here to avoid warnings about
# unused utility functions and/or temps
...
...
@@ -7195,6 +7204,8 @@ class TryFinallyStatNode(StatNode):
code
.
globalstate
.
use_utility_code
(
reset_exception_utility_code
)
if
self
.
is_try_finally_in_nogil
:
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
code
.
putln
(
"__Pyx_PyThreadState_assign"
)
# re-assign in case a generator yielded
# not using preprocessor here to avoid warnings about
# unused utility functions and/or temps
code
.
putln
(
"if (PY_MAJOR_VERSION >= 3) {"
)
...
...
@@ -8836,13 +8847,14 @@ traceback_utility_code = UtilityCode.load_cached("AddTraceback", "Exceptions.c")
#------------------------------------------------------------------------------------
get_exception_tuple_utility_code
=
UtilityCode
(
proto
=
"""
static PyObject *__Pyx_GetExceptionTuple(
void
); /*proto*/
static PyObject *__Pyx_GetExceptionTuple(
PyThreadState *__pyx_tstate
); /*proto*/
"""
,
# I doubt that calling __Pyx_GetException() here is correct as it moves
# the exception from tstate->curexc_* to tstate->exc_*, which prevents
# exception handlers later on from receiving it.
# NOTE: "__pyx_tstate" may be used by __Pyx_GetException() macro
impl
=
"""
static PyObject *__Pyx_GetExceptionTuple(
void
) {
static PyObject *__Pyx_GetExceptionTuple(
CYTHON_UNUSED PyThreadState *__pyx_tstate
) {
PyObject *type = NULL, *value = NULL, *tb = NULL;
if (__Pyx_GetException(&type, &value, &tb) == 0) {
PyObject* exc_info = PyTuple_New(3);
...
...
Cython/Utility/Builtins.c
View file @
832da3bf
...
...
@@ -167,13 +167,12 @@ bad:
static
CYTHON_INLINE
PyObject
*
__Pyx_GetAttr3
(
PyObject
*
,
PyObject
*
,
PyObject
*
);
/*proto*/
//////////////////// GetAttr3 ////////////////////
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: ObjectHandling.c::GetAttr
static
CYTHON_INLINE
PyObject
*
__Pyx_GetAttr3
(
PyObject
*
o
,
PyObject
*
n
,
PyObject
*
d
)
{
PyObject
*
r
=
__Pyx_GetAttr
(
o
,
n
);
if
(
unlikely
(
!
r
))
{
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
goto
bad
;
PyErr_Clear
();
r
=
d
;
...
...
Cython/Utility/Coroutine.c
View file @
832da3bf
...
...
@@ -177,7 +177,6 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//////////////////// AsyncIter ////////////////////
//@requires: GetAwaitIter
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: ObjectHandling.c::PyObjectCallMethod0
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_GetAsyncIter
(
PyObject
*
obj
)
{
...
...
@@ -193,7 +192,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
if
(
likely
(
iter
))
return
iter
;
// FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__aiter__'
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
return
NULL
;
}
#else
...
...
@@ -220,7 +219,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
return
value
;
}
// FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__anext__'
if
(
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
if
(
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
#endif
PyErr_Format
(
PyExc_TypeError
,
"'async for' requires an object with __anext__ method, got %.100s"
,
Py_TYPE
(
obj
)
->
tp_name
);
...
...
@@ -307,10 +306,10 @@ static int __pyx_Generator_init(void); /*proto*/
//////////////////// CoroutineBase ////////////////////
//@substitute: naming
//@requires: Exceptions.c::PyErrFetchRestore
//@requires: Exceptions.c::SwapException
//@requires: Exceptions.c::RaiseException
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: ObjectHandling.c::PyObjectCallMethod1
//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@requires: CommonTypes.c::FetchCommonType
...
...
@@ -452,6 +451,7 @@ int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_SendEx
(
__pyx_CoroutineObject
*
self
,
PyObject
*
value
)
{
PyObject
*
retval
;
__Pyx_PyThreadState_declare
assert
(
!
self
->
is_running
);
...
...
@@ -469,7 +469,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
return
NULL
;
}
__Pyx_PyThreadState_assign
if
(
value
)
{
#if CYTHON_COMPILING_IN_PYPY
// FIXME: what to do in PyPy?
...
...
@@ -477,13 +477,12 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
// Generators always return to their most recent caller, not
// necessarily their creator.
if
(
self
->
exc_traceback
)
{
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyTracebackObject
*
tb
=
(
PyTracebackObject
*
)
self
->
exc_traceback
;
PyFrameObject
*
f
=
tb
->
tb_frame
;
Py_XINCREF
(
tstat
e
->
frame
);
Py_XINCREF
(
$
local_tstate_cnam
e
->
frame
);
assert
(
f
->
f_back
==
NULL
);
f
->
f_back
=
tstat
e
->
frame
;
f
->
f_back
=
$
local_tstate_cnam
e
->
frame
;
}
#endif
__Pyx_ExceptionSwap
(
&
self
->
exc_type
,
&
self
->
exc_value
,
...
...
@@ -604,7 +603,7 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
gen
->
is_running
=
1
;
meth
=
__Pyx_PyObject_GetAttrStr
(
yf
,
PYIDENT
(
"close"
));
if
(
unlikely
(
!
meth
))
{
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
PyErr_WriteUnraisable
(
yf
);
}
PyErr_Clear
();
...
...
@@ -720,7 +719,7 @@ static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
PyObject
*
meth
=
__Pyx_PyObject_GetAttrStr
(
yf
,
PYIDENT
(
"throw"
));
if
(
unlikely
(
!
meth
))
{
Py_DECREF
(
yf
);
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
gen
->
is_running
=
0
;
return
NULL
;
}
...
...
Cython/Utility/Exceptions.c
View file @
832da3bf
...
...
@@ -5,19 +5,33 @@
// 'except' statement, curexc_* is moved over to exc_* by
// __Pyx_GetException()
/////////////// PyThreadStateGet.proto ///////////////
//@substitute: naming
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname;
#define __Pyx_PyThreadState_assign $local_tstate_cname = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif
/////////////// PyErrExceptionMatches.proto ///////////////
//@substitute: naming
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
int
__Pyx_PyErr_ExceptionMatches
(
PyObject
*
err
);
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesState(err, $local_tstate_cname)
static
CYTHON_INLINE
int
__Pyx_PyErr_ExceptionMatchesState
(
PyObject
*
err
,
PyThreadState
*
tstate
);
#else
#define __Pyx_PyErr_ExceptionMatches(e
xc_type
) PyErr_ExceptionMatches(exc_type)
#define __Pyx_PyErr_ExceptionMatches(e
rr
) PyErr_ExceptionMatches(exc_type)
#endif
/////////////// PyErrExceptionMatches ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
int
__Pyx_PyErr_ExceptionMatches
(
PyObject
*
err
)
{
PyObject
*
exc_type
=
PyThreadState_GET
()
->
curexc_type
;
static
CYTHON_INLINE
int
__Pyx_PyErr_ExceptionMatches
State
(
PyObject
*
err
,
PyThreadState
*
tstate
)
{
PyObject
*
exc_type
=
tstate
->
curexc_type
;
if
(
exc_type
==
err
)
return
1
;
if
(
unlikely
(
!
exc_type
))
return
0
;
return
PyErr_GivenExceptionMatches
(
exc_type
,
err
);
...
...
@@ -260,16 +274,25 @@ bad:
#endif
/////////////// GetException.proto ///////////////
//@substitute: naming
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_GetException(type, value, tb) __Pyx__GetException($local_tstate_cname, type, value, tb)
static
int
__Pyx__GetException
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
#else
static
int
__Pyx_GetException
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
#endif
/////////////// GetException ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
int
__Pyx__GetException
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
#else
static
int
__Pyx_GetException
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
#endif
PyObject
*
local_type
,
*
local_value
,
*
local_tb
;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
PyThreadState
*
tstate
=
PyThreadState_GET
();
local_type
=
tstate
->
curexc_type
;
local_value
=
tstate
->
curexc_value
;
local_tb
=
tstate
->
curexc_traceback
;
...
...
@@ -363,30 +386,35 @@ static CYTHON_INLINE void __Pyx_ReraiseException(void) {
}
/////////////// SaveResetException.proto ///////////////
//@substitute: naming
//@requires: PyThreadStateGet
static
CYTHON_INLINE
void
__Pyx_ExceptionSave
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
static
void
__Pyx_ExceptionReset
(
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
tb
);
/*proto*/
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave($local_tstate_cname, type, value, tb)
static
CYTHON_INLINE
void
__Pyx__ExceptionSave
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset($local_tstate_cname, type, value, tb)
static
CYTHON_INLINE
void
__Pyx__ExceptionReset
(
PyThreadState
*
tstate
,
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
tb
);
/*proto*/
#else
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
#endif
/////////////// SaveResetException ///////////////
static
CYTHON_INLINE
void
__Pyx_ExceptionSave
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState
*
tstate
=
PyThreadState_GET
();
static
CYTHON_INLINE
void
__Pyx__ExceptionSave
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
*
type
=
tstate
->
exc_type
;
*
value
=
tstate
->
exc_value
;
*
tb
=
tstate
->
exc_traceback
;
Py_XINCREF
(
*
type
);
Py_XINCREF
(
*
value
);
Py_XINCREF
(
*
tb
);
#else
PyErr_GetExcInfo
(
type
,
value
,
tb
);
#endif
}
static
void
__Pyx_ExceptionReset
(
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
tb
)
{
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
void
__Pyx__ExceptionReset
(
PyThreadState
*
tstate
,
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
PyThreadState
*
tstate
=
PyThreadState_GET
();
tmp_type
=
tstate
->
exc_type
;
tmp_value
=
tstate
->
exc_value
;
tmp_tb
=
tstate
->
exc_traceback
;
...
...
@@ -396,22 +424,25 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb)
Py_XDECREF
(
tmp_type
);
Py_XDECREF
(
tmp_value
);
Py_XDECREF
(
tmp_tb
);
#else
PyErr_SetExcInfo
(
type
,
value
,
tb
);
#endif
}
#endif
/////////////// SwapException.proto ///////////////
//@substitute: naming
//@requires: PyThreadStateGet
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap($local_tstate_cname, type, value, tb)
static
CYTHON_INLINE
void
__Pyx__ExceptionSwap
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
#else
static
CYTHON_INLINE
void
__Pyx_ExceptionSwap
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
);
/*proto*/
#endif
/////////////// SwapException ///////////////
static
CYTHON_INLINE
void
__Pyx_ExceptionSwap
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState
*
tstate
=
PyThreadState_GET
();
static
CYTHON_INLINE
void
__Pyx__ExceptionSwap
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
tmp_type
=
tstate
->
exc_type
;
tmp_value
=
tstate
->
exc_value
;
tmp_tb
=
tstate
->
exc_traceback
;
...
...
@@ -419,15 +450,23 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
tstate
->
exc_type
=
*
type
;
tstate
->
exc_value
=
*
value
;
tstate
->
exc_traceback
=
*
tb
;
*
type
=
tmp_type
;
*
value
=
tmp_value
;
*
tb
=
tmp_tb
;
}
#else
static
CYTHON_INLINE
void
__Pyx_ExceptionSwap
(
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
PyErr_GetExcInfo
(
&
tmp_type
,
&
tmp_value
,
&
tmp_tb
);
PyErr_SetExcInfo
(
*
type
,
*
value
,
*
tb
);
#endif
*
type
=
tmp_type
;
*
value
=
tmp_value
;
*
tb
=
tmp_tb
;
}
#endif
/////////////// WriteUnraisableException.proto ///////////////
...
...
Cython/Utility/FunctionArguments.c
View file @
832da3bf
...
...
@@ -308,7 +308,6 @@ bad:
static
int
__Pyx_MergeKeywords
(
PyObject
*
kwdict
,
PyObject
*
source_mapping
);
/*proto*/
//////////////////// MergeKeywords ////////////////////
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: RaiseDoubleKeywords
//@requires: Optimize.c::dict_iter
...
...
@@ -321,7 +320,7 @@ static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
if
(
unlikely
(
!
iter
))
{
// slow fallback: try converting to dict, then iterate
PyObject
*
args
;
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
goto
bad
;
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
goto
bad
;
PyErr_Clear
();
args
=
PyTuple_Pack
(
1
,
source_mapping
);
if
(
likely
(
args
))
{
...
...
Cython/Utility/ObjectHandling.c
View file @
832da3bf
...
...
@@ -268,7 +268,6 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
int
is_list
,
int
wraparound
,
int
boundscheck
);
/////////////// GetItemInt ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
static
CYTHON_INLINE
PyObject
*
__Pyx_GetItemInt_Generic
(
PyObject
*
o
,
PyObject
*
j
)
{
PyObject
*
r
;
...
...
@@ -325,7 +324,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
i
+=
l
;
}
else
{
// if length > max(Py_ssize_t), maybe the object can wrap around itself?
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
return
NULL
;
PyErr_Clear
();
}
...
...
@@ -354,7 +353,6 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
int
is_list
,
int
wraparound
,
int
boundscheck
);
/////////////// SetItemInt ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
static
CYTHON_INLINE
int
__Pyx_SetItemInt_Generic
(
PyObject
*
o
,
PyObject
*
j
,
PyObject
*
v
)
{
int
r
;
...
...
@@ -386,7 +384,7 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
i
+=
l
;
}
else
{
// if length > max(Py_ssize_t), maybe the object can wrap around itself?
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
return
-
1
;
PyErr_Clear
();
}
...
...
@@ -420,7 +418,6 @@ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
int
is_list
,
int
wraparound
);
/////////////// DelItemInt ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
static
CYTHON_INLINE
int
__Pyx_DelItem_Generic
(
PyObject
*
o
,
PyObject
*
j
)
{
int
r
;
...
...
@@ -446,7 +443,7 @@ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
i
+=
l
;
}
else
{
// if length > max(Py_ssize_t), maybe the object can wrap around itself?
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
return
-
1
;
PyErr_Clear
();
}
...
...
@@ -478,7 +475,6 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
{{
endif
}}
/////////////// SliceObject ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
{{
if
access
==
'
Get
'
}}
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_GetSlice
(
PyObject
*
obj
,
...
...
@@ -520,7 +516,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
}
}
else
{
// if length > max(Py_ssize_t), maybe the object can wrap around itself?
if
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
goto
bad
;
PyErr_Clear
();
}
...
...
@@ -833,7 +829,6 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
PyObject
*
mkw
,
int
calculate_metaclass
,
int
allow_py2_metaclass
);
/*proto*/
/////////////// Py3ClassCreate ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: PyObjectGetAttrStr
//@requires: CalculateMetaclass
...
...
@@ -852,7 +847,7 @@ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases,
Py_DECREF
(
prep
);
Py_DECREF
(
pargs
);
}
else
{
if
(
unlikely
(
!
__Pyx_
PyErr_ExceptionMatches
(
PyExc_AttributeError
)))
if
(
unlikely
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
)))
return
NULL
;
PyErr_Clear
();
ns
=
PyDict_New
();
...
...
@@ -884,7 +879,7 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
owned_metaclass
=
PyObject_GetItem
(
dict
,
PYIDENT
(
"__metaclass__"
));
if
(
owned_metaclass
)
{
metaclass
=
owned_metaclass
;
}
else
if
(
likely
(
__Pyx_
PyErr_ExceptionMatches
(
PyExc_KeyError
)))
{
}
else
if
(
likely
(
PyErr_ExceptionMatches
(
PyExc_KeyError
)))
{
PyErr_Clear
();
}
else
{
return
NULL
;
...
...
@@ -1496,7 +1491,6 @@ static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y);
#endif
/////////////// MatrixMultiply ///////////////
//@requires: Exceptions.c::PyErrExceptionMatches
//@requires: PyObjectGetAttrStr
//@requires: PyObjectCallOneArg
...
...
@@ -1539,7 +1533,7 @@ bad:
return result; \
Py_DECREF(result); \
} else { \
if (!
__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))
\
if (!
PyErr_ExceptionMatches(PyExc_AttributeError))
\
return NULL; \
PyErr_Clear(); \
} \
...
...
Cython/Utility/Profile.c
View file @
832da3bf
...
...
@@ -90,7 +90,7 @@
(tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) { \
tstate->tracing++; \
tstate->use_tracing = 0; \
PyObject *exc_info = __Pyx_GetExceptionTuple(
);
\
PyObject *exc_info = __Pyx_GetExceptionTuple(
tstate);
\
if (exc_info) { \
if (CYTHON_TRACE && tstate->c_tracefunc) \
tstate->c_tracefunc( \
...
...
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