Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
13800032
Commit
13800032
authored
Dec 19, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sys.exc_info()
parent
da7b2d7f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
25 deletions
+34
-25
src/core/threading.h
src/core/threading.h
+1
-1
src/gc/root_finder.cpp
src/gc/root_finder.cpp
+12
-12
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+9
-0
src/runtime/capi.cpp
src/runtime/capi.cpp
+12
-12
No files found.
src/core/threading.h
View file @
13800032
...
...
@@ -32,7 +32,7 @@ namespace threading {
bool
threadWasStarted
();
struct
ThreadState
{
Box
*
curexc_type
,
*
curexc_value
,
*
cur
exc_traceback
;
Box
*
exc_type
,
*
exc_value
,
*
exc_traceback
;
};
extern
__thread
ThreadState
cur_thread_state
;
...
...
src/gc/root_finder.cpp
View file @
13800032
...
...
@@ -55,12 +55,12 @@ void collectOtherThreadsStacks(TraceStack* stack) {
collectRoots
(
tstate
.
stack_start
,
tstate
.
stack_end
,
stack
);
collectRoots
(
tstate
.
ucontext
,
tstate
.
ucontext
+
1
,
stack
);
if
(
tstate
.
thread_state
->
cur
exc_type
)
v
.
visit
(
tstate
.
thread_state
->
cur
exc_type
);
if
(
tstate
.
thread_state
->
cur
exc_value
)
v
.
visit
(
tstate
.
thread_state
->
cur
exc_value
);
if
(
tstate
.
thread_state
->
cur
exc_traceback
)
v
.
visit
(
tstate
.
thread_state
->
cur
exc_traceback
);
if
(
tstate
.
thread_state
->
exc_type
)
v
.
visit
(
tstate
.
thread_state
->
exc_type
);
if
(
tstate
.
thread_state
->
exc_value
)
v
.
visit
(
tstate
.
thread_state
->
exc_value
);
if
(
tstate
.
thread_state
->
exc_traceback
)
v
.
visit
(
tstate
.
thread_state
->
exc_traceback
);
}
}
...
...
@@ -86,12 +86,12 @@ static void collectLocalStack(TraceStack* stack) {
#endif
GCVisitor
v
(
stack
);
if
(
threading
::
cur_thread_state
.
cur
exc_type
)
v
.
visit
(
threading
::
cur_thread_state
.
cur
exc_type
);
if
(
threading
::
cur_thread_state
.
cur
exc_value
)
v
.
visit
(
threading
::
cur_thread_state
.
cur
exc_value
);
if
(
threading
::
cur_thread_state
.
cur
exc_traceback
)
v
.
visit
(
threading
::
cur_thread_state
.
cur
exc_traceback
);
if
(
threading
::
cur_thread_state
.
exc_type
)
v
.
visit
(
threading
::
cur_thread_state
.
exc_type
);
if
(
threading
::
cur_thread_state
.
exc_value
)
v
.
visit
(
threading
::
cur_thread_state
.
exc_value
);
if
(
threading
::
cur_thread_state
.
exc_traceback
)
v
.
visit
(
threading
::
cur_thread_state
.
exc_traceback
);
}
void
collectStackRoots
(
TraceStack
*
stack
)
{
...
...
src/runtime/builtin_modules/sys.cpp
View file @
13800032
...
...
@@ -31,6 +31,13 @@ namespace pyston {
BoxedModule
*
sys_module
;
BoxedDict
*
sys_modules_dict
;
Box
*
sysExcInfo
()
{
return
new
BoxedTuple
(
{
threading
::
cur_thread_state
.
exc_type
?
threading
::
cur_thread_state
.
exc_type
:
None
,
threading
::
cur_thread_state
.
exc_value
?
threading
::
cur_thread_state
.
exc_value
:
None
,
threading
::
cur_thread_state
.
exc_traceback
?
threading
::
cur_thread_state
.
exc_traceback
:
None
});
}
BoxedDict
*
getSysModulesDict
()
{
// PyPy's behavior: fetch from sys.modules each time:
// Box *_sys_modules = sys_module->getattr("modules");
...
...
@@ -134,6 +141,8 @@ void setupSys() {
sys_module
->
giveAttr
(
"stdin"
,
new
BoxedFile
(
stdin
,
"<stdin>"
,
"r"
));
sys_module
->
giveAttr
(
"stderr"
,
new
BoxedFile
(
stderr
,
"<stderr>"
,
"w"
));
sys_module
->
giveAttr
(
"exc_info"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
sysExcInfo
,
BOXED_TUPLE
,
0
)));
sys_module
->
giveAttr
(
"warnoptions"
,
new
BoxedList
());
sys_module
->
giveAttr
(
"py3kwarning"
,
False
);
...
...
src/runtime/capi.cpp
View file @
13800032
...
...
@@ -630,30 +630,30 @@ extern "C" int PyCallable_Check(PyObject* x) {
}
void
checkAndThrowCAPIException
()
{
Box
*
value
=
threading
::
cur_thread_state
.
cur
exc_value
;
Box
*
value
=
threading
::
cur_thread_state
.
exc_value
;
if
(
value
)
{
RELEASE_ASSERT
(
threading
::
cur_thread_state
.
cur
exc_traceback
==
NULL
,
"unsupported"
);
RELEASE_ASSERT
(
threading
::
cur_thread_state
.
exc_traceback
==
NULL
,
"unsupported"
);
// This doesn't seem like the right behavior...
if
(
value
->
cls
!=
threading
::
cur_thread_state
.
cur
exc_type
)
{
if
(
value
->
cls
!=
threading
::
cur_thread_state
.
exc_type
)
{
if
(
value
->
cls
==
tuple_cls
)
value
=
runtimeCall
(
threading
::
cur_thread_state
.
curexc_type
,
ArgPassSpec
(
0
,
0
,
true
,
false
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
value
=
runtimeCall
(
threading
::
cur_thread_state
.
exc_type
,
ArgPassSpec
(
0
,
0
,
true
,
false
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
else
value
=
runtimeCall
(
threading
::
cur_thread_state
.
curexc_type
,
ArgPassSpec
(
1
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
value
=
runtimeCall
(
threading
::
cur_thread_state
.
exc_type
,
ArgPassSpec
(
1
),
value
,
NULL
,
NULL
,
NULL
,
NULL
);
}
RELEASE_ASSERT
(
value
->
cls
==
threading
::
cur_thread_state
.
cur
exc_type
,
"unsupported"
);
RELEASE_ASSERT
(
value
->
cls
==
threading
::
cur_thread_state
.
exc_type
,
"unsupported"
);
PyErr_Clear
();
throw
value
;
}
}
extern
"C"
void
PyErr_Restore
(
PyObject
*
type
,
PyObject
*
value
,
PyObject
*
traceback
)
{
threading
::
cur_thread_state
.
cur
exc_type
=
type
;
threading
::
cur_thread_state
.
cur
exc_value
=
value
;
threading
::
cur_thread_state
.
cur
exc_traceback
=
traceback
;
threading
::
cur_thread_state
.
exc_type
=
type
;
threading
::
cur_thread_state
.
exc_value
=
value
;
threading
::
cur_thread_state
.
exc_traceback
=
traceback
;
}
extern
"C"
void
PyErr_Clear
()
{
...
...
@@ -685,7 +685,7 @@ extern "C" int PyErr_ExceptionMatches(PyObject* exc) {
}
extern
"C"
PyObject
*
PyErr_Occurred
()
{
return
threading
::
cur_thread_state
.
cur
exc_type
;
return
threading
::
cur_thread_state
.
exc_type
;
}
extern
"C"
int
PyErr_WarnEx
(
PyObject
*
category
,
const
char
*
text
,
Py_ssize_t
stacklevel
)
{
...
...
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