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
f7bcf72f
Commit
f7bcf72f
authored
Sep 15, 2018
by
scoder
Committed by
GitHub
Sep 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2607 from scoder/gen_exc_py37_fix
Use exception stack in Py3.7
parents
c6320307
94b121da
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1544 additions
and
79 deletions
+1544
-79
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+6
-1
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+98
-48
Cython/Utility/Exceptions.c
Cython/Utility/Exceptions.c
+64
-30
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+7
-0
runtests.py
runtests.py
+2
-0
tests/run/test_exceptions.pyx
tests/run/test_exceptions.pyx
+1367
-0
No files found.
Cython/Compiler/Nodes.py
View file @
f7bcf72f
...
...
@@ -4256,7 +4256,10 @@ class GeneratorBodyDefNode(DefNode):
code
.
put_xgiveref
(
Naming
.
retval_cname
)
else
:
code
.
put_xdecref_clear
(
Naming
.
retval_cname
,
py_object_type
)
# For Py3.7, clearing is already done below.
code
.
putln
(
"#if !CYTHON_USE_EXC_INFO_STACK"
)
code
.
putln
(
"__Pyx_Coroutine_ResetAndClearException(%s);"
%
Naming
.
generator_cname
)
code
.
putln
(
"#endif"
)
code
.
putln
(
'%s->resume_label = -1;'
%
Naming
.
generator_cname
)
# clean up as early as possible to help breaking any reference cycles
code
.
putln
(
'__Pyx_Coroutine_clear((PyObject*)%s);'
%
Naming
.
generator_cname
)
...
...
@@ -7408,7 +7411,9 @@ class ExceptClauseNode(Node):
if
not
self
.
body
.
is_terminator
:
for
var
in
exc_vars
:
code
.
put_decref_clear
(
var
,
py_object_type
)
# FIXME: XDECREF() is needed to allow re-raising (which clears the exc_vars),
# but I don't think it's the right solution.
code
.
put_xdecref_clear
(
var
,
py_object_type
)
code
.
put_goto
(
end_label
)
for
new_label
,
old_label
in
[(
code
.
break_label
,
old_break_label
),
...
...
Cython/Utility/Coroutine.c
View file @
f7bcf72f
This diff is collapsed.
Click to expand it.
Cython/Utility/Exceptions.c
View file @
f7bcf72f
...
...
@@ -307,6 +307,31 @@ bad:
}
#endif
/////////////// GetTopmostException.proto ///////////////
#if CYTHON_USE_EXC_INFO_STACK
static
_PyErr_StackItem
*
__Pyx_PyErr_GetTopmostException
(
PyThreadState
*
tstate
);
#endif
/////////////// GetTopmostException ///////////////
#if CYTHON_USE_EXC_INFO_STACK
// Copied from errors.c in CPython.
static
_PyErr_StackItem
*
__Pyx_PyErr_GetTopmostException
(
PyThreadState
*
tstate
)
{
_PyErr_StackItem
*
exc_info
=
tstate
->
exc_info
;
while
((
exc_info
->
exc_type
==
NULL
||
exc_info
->
exc_type
==
Py_None
)
&&
exc_info
->
previous_item
!=
NULL
)
{
exc_info
=
exc_info
->
previous_item
;
}
return
exc_info
;
}
#endif
/////////////// GetException.proto ///////////////
//@substitute: naming
//@requires: PyThreadStateGet
...
...
@@ -360,13 +385,16 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
*
value
=
local_value
;
*
tb
=
local_tb
;
#if CYTHON_FAST_THREAD_STATE
#if PY_VERSION_HEX >= 0x030700A3
tmp_type
=
tstate
->
exc_state
.
exc_type
;
tmp_value
=
tstate
->
exc_state
.
exc_value
;
tmp_tb
=
tstate
->
exc_state
.
exc_traceback
;
tstate
->
exc_state
.
exc_type
=
local_type
;
tstate
->
exc_state
.
exc_value
=
local_value
;
tstate
->
exc_state
.
exc_traceback
=
local_tb
;
#if CYTHON_USE_EXC_INFO_STACK
{
_PyErr_StackItem
*
exc_info
=
tstate
->
exc_info
;
tmp_type
=
exc_info
->
exc_type
;
tmp_value
=
exc_info
->
exc_value
;
tmp_tb
=
exc_info
->
exc_traceback
;
exc_info
->
exc_type
=
local_type
;
exc_info
->
exc_value
=
local_value
;
exc_info
->
exc_traceback
=
local_tb
;
}
#else
tmp_type
=
tstate
->
exc_type
;
tmp_value
=
tstate
->
exc_value
;
...
...
@@ -398,16 +426,18 @@ bad:
static
CYTHON_INLINE
void
__Pyx_ReraiseException
(
void
);
/*proto*/
/////////////// ReRaiseException.proto ///////////////
/////////////// ReRaiseException ///////////////
//@requires: GetTopmostException
static
CYTHON_INLINE
void
__Pyx_ReraiseException
(
void
)
{
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
;
#if CYTHON_FAST_THREAD_STATE
PyThreadState
*
tstate
=
PyThreadState_GET
();
#if PY_VERSION_HEX >= 0x030700A3
type
=
tstate
->
exc_state
.
exc_type
;
value
=
tstate
->
exc_state
.
exc_value
;
tb
=
tstate
->
exc_state
.
exc_traceback
;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem
*
exc_info
=
__Pyx_PyErr_GetTopmostException
(
tstate
);
type
=
exc_info
->
exc_type
;
value
=
exc_info
->
exc_value
;
tb
=
exc_info
->
exc_traceback
;
#else
type
=
tstate
->
exc_type
;
value
=
tstate
->
exc_value
;
...
...
@@ -453,13 +483,15 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject
#endif
/////////////// SaveResetException ///////////////
//@requires: GetTopmostException
#if CYTHON_FAST_THREAD_STATE
static
CYTHON_INLINE
void
__Pyx__ExceptionSave
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
#if PY_VERSION_HEX >= 0x030700A3
*
type
=
tstate
->
exc_state
.
exc_type
;
*
value
=
tstate
->
exc_state
.
exc_value
;
*
tb
=
tstate
->
exc_state
.
exc_traceback
;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem
*
exc_info
=
__Pyx_PyErr_GetTopmostException
(
tstate
);
*
type
=
exc_info
->
exc_type
;
*
value
=
exc_info
->
exc_value
;
*
tb
=
exc_info
->
exc_traceback
;
#else
*
type
=
tstate
->
exc_type
;
*
value
=
tstate
->
exc_value
;
...
...
@@ -473,13 +505,14 @@ static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject *
static
CYTHON_INLINE
void
__Pyx__ExceptionReset
(
PyThreadState
*
tstate
,
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
#if PY_VERSION_HEX >= 0x030700A3
tmp_type
=
tstate
->
exc_state
.
exc_type
;
tmp_value
=
tstate
->
exc_state
.
exc_value
;
tmp_tb
=
tstate
->
exc_state
.
exc_traceback
;
tstate
->
exc_state
.
exc_type
=
type
;
tstate
->
exc_state
.
exc_value
=
value
;
tstate
->
exc_state
.
exc_traceback
=
tb
;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem
*
exc_info
=
tstate
->
exc_info
;
tmp_type
=
exc_info
->
exc_type
;
tmp_value
=
exc_info
->
exc_value
;
tmp_tb
=
exc_info
->
exc_traceback
;
exc_info
->
exc_type
=
type
;
exc_info
->
exc_value
=
value
;
exc_info
->
exc_traceback
=
tb
;
#else
tmp_type
=
tstate
->
exc_type
;
tmp_value
=
tstate
->
exc_value
;
...
...
@@ -511,14 +544,15 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
static
CYTHON_INLINE
void
__Pyx__ExceptionSwap
(
PyThreadState
*
tstate
,
PyObject
**
type
,
PyObject
**
value
,
PyObject
**
tb
)
{
PyObject
*
tmp_type
,
*
tmp_value
,
*
tmp_tb
;
#if PY_VERSION_HEX >= 0x030700A3
tmp_type
=
tstate
->
exc_state
.
exc_type
;
tmp_value
=
tstate
->
exc_state
.
exc_value
;
tmp_tb
=
tstate
->
exc_state
.
exc_traceback
;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem
*
exc_info
=
tstate
->
exc_info
;
tmp_type
=
exc_info
->
exc_type
;
tmp_value
=
exc_info
->
exc_value
;
tmp_tb
=
exc_info
->
exc_traceback
;
tstate
->
exc_state
.
exc_type
=
*
type
;
tstate
->
exc_state
.
exc_value
=
*
value
;
tstate
->
exc_state
.
exc_traceback
=
*
tb
;
exc_info
->
exc_type
=
*
type
;
exc_info
->
exc_value
=
*
value
;
exc_info
->
exc_traceback
=
*
tb
;
#else
tmp_type
=
tstate
->
exc_type
;
tmp_value
=
tstate
->
exc_value
;
...
...
Cython/Utility/ModuleSetupCode.c
View file @
f7bcf72f
...
...
@@ -81,6 +81,8 @@
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
...
...
@@ -122,6 +124,8 @@
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
...
...
@@ -186,6 +190,9 @@
#ifndef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
#endif
#ifndef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
...
...
runtests.py
View file @
f7bcf72f
...
...
@@ -145,6 +145,7 @@ EXT_DEP_MODULES = {
'Coverage'
:
'Cython.Coverage'
,
'tag:ipython'
:
'IPython.testing.globalipapp'
,
'tag:jedi'
:
'jedi_BROKEN_AND_DISABLED'
,
'tag:test.support'
:
'test.support'
,
# support module for CPython unit tests
}
def
patch_inspect_isfunction
():
...
...
@@ -433,6 +434,7 @@ VER_DEP_MODULES = {
'run.py35_asyncio_async_def',
'run.mod__spec__',
'run.pep526_variable_annotations', # typing module
'run.test_exceptions', # copied from Py3.7+
]),
}
...
...
tests/run/test_exceptions.pyx
0 → 100644
View file @
f7bcf72f
This diff is collapsed.
Click to expand it.
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