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
a230632b
Commit
a230632b
authored
May 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #521 from kmod/sys_excepthook
Fix "sys.excepthook is missing" warnings
parents
06f5410d
4189f25f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+22
-0
src/runtime/types.h
src/runtime/types.h
+1
-1
test/tests/sys_test.py
test/tests/sys_test.py
+6
-0
No files found.
src/runtime/builtin_modules/sys.cpp
View file @
a230632b
...
...
@@ -20,6 +20,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "capi/types.h"
#include "codegen/unwinding.h"
#include "core/types.h"
#include "gc/collector.h"
...
...
@@ -381,6 +382,23 @@ extern "C" const char* Py_GetPlatform() noexcept {
#endif
}
static
PyObject
*
sys_excepthook
(
PyObject
*
self
,
PyObject
*
args
)
noexcept
{
PyObject
*
exc
,
*
value
,
*
tb
;
if
(
!
PyArg_UnpackTuple
(
args
,
"excepthook"
,
3
,
3
,
&
exc
,
&
value
,
&
tb
))
return
NULL
;
PyErr_Display
(
exc
,
value
,
tb
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
PyDoc_STRVAR
(
excepthook_doc
,
"excepthook(exctype, value, traceback) -> None
\n
"
"
\n
"
"Handle an exception by displaying it with a traceback on sys.stderr.
\n
"
);
static
PyMethodDef
sys_methods
[]
=
{
{
"excepthook"
,
sys_excepthook
,
METH_VARARGS
,
excepthook_doc
},
};
void
setupSys
()
{
sys_modules_dict
=
new
BoxedDict
();
gc
::
registerPermanentRoot
(
sys_modules_dict
);
...
...
@@ -482,6 +500,10 @@ void setupSys() {
sys_flags_cls
->
tp_mro
=
BoxedTuple
::
create
({
sys_flags_cls
,
object_cls
});
sys_flags_cls
->
freeze
();
for
(
auto
&
md
:
sys_methods
)
{
sys_module
->
giveAttr
(
md
.
ml_name
,
new
BoxedCApiFunction
(
md
.
ml_flags
,
sys_module
,
md
.
ml_name
,
md
.
ml_meth
));
}
sys_module
->
giveAttr
(
"flags"
,
new
BoxedSysFlags
());
}
...
...
src/runtime/types.h
View file @
a230632b
...
...
@@ -87,7 +87,7 @@ extern BoxedClass* object_cls, *type_cls, *bool_cls, *int_cls, *long_cls, *float
*
none_cls
,
*
instancemethod_cls
,
*
list_cls
,
*
slice_cls
,
*
module_cls
,
*
dict_cls
,
*
tuple_cls
,
*
file_cls
,
*
enumerate_cls
,
*
xrange_cls
,
*
member_descriptor_cls
,
*
method_cls
,
*
closure_cls
,
*
generator_cls
,
*
complex_cls
,
*
basestring_cls
,
*
property_cls
,
*
staticmethod_cls
,
*
classmethod_cls
,
*
attrwrapper_cls
,
*
pyston_getset_cls
,
*
capi_getset_cls
,
*
builtin_function_or_method_cls
,
*
set_cls
,
*
frozenset_cls
,
*
code_cls
;
*
capi_getset_cls
,
*
builtin_function_or_method_cls
,
*
set_cls
,
*
frozenset_cls
,
*
code_cls
,
*
frame_cls
;
}
#define unicode_cls (&PyUnicode_Type)
#define memoryview_cls (&PyMemoryView_Type)
...
...
test/tests/sys_test.py
View file @
a230632b
...
...
@@ -11,3 +11,9 @@ print type(sys.maxsize)
print
sys
.
stdout
is
sys
.
__stdout__
print
sys
.
stderr
is
sys
.
__stderr__
print
sys
.
stdin
is
sys
.
__stdin__
try
:
1
/
0
except
ZeroDivisionError
:
# Our tester won't check the output of this, but at least we can make sure it exists and runs:
sys
.
excepthook
(
*
sys
.
exc_info
())
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