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
45458e12
Commit
45458e12
authored
Dec 17, 2015
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply some pyston changes and enable PyErr_WarnEx
parent
b4069ea9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
33 deletions
+40
-33
from_cpython/Include/frameobject.h
from_cpython/Include/frameobject.h
+7
-0
from_cpython/Include/sysmodule.h
from_cpython/Include/sysmodule.h
+3
-0
from_cpython/Include/warnings.h
from_cpython/Include/warnings.h
+1
-1
from_cpython/Python/_warnings.c
from_cpython/Python/_warnings.c
+13
-13
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+5
-0
src/runtime/capi.cpp
src/runtime/capi.cpp
+5
-19
src/runtime/frame.cpp
src/runtime/frame.cpp
+4
-0
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
No files found.
from_cpython/Include/frameobject.h
View file @
45458e12
...
...
@@ -7,6 +7,8 @@
extern
"C"
{
#endif
// Pyston changes: we don't use it for now.
#if 0
typedef struct {
int b_type; /* what kind of block this is */
int b_handler; /* where to jump to find handler */
...
...
@@ -82,7 +84,12 @@ PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
#endif
/* Return the line of code the frame is currently executing. */
PyAPI_FUNC
(
int
)
PyFrame_GetLineNumber
(
PyObject
*
)
PYSTON_NOEXCEPT
;
// Pyston changes: add a function to get globals
PyAPI_FUNC
(
PyObject
*
)
PyFrame_GetGlobals
(
PyObject
*
)
PYSTON_NOEXCEPT
;
// Pyston changes: add a function to get frame object by level
PyAPI_FUNC
(
PyObject
*
)
PyFrame_ForStackLevel
(
int
stack_level
)
PYSTON_NOEXCEPT
;
#ifdef __cplusplus
}
#endif
#endif
/* !Py_FRAMEOBJECT_H */
from_cpython/Include/sysmodule.h
View file @
45458e12
...
...
@@ -25,6 +25,9 @@ PyAPI_FUNC(void) PySys_ResetWarnOptions(void) PYSTON_NOEXCEPT;
PyAPI_FUNC
(
void
)
PySys_AddWarnOption
(
char
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PySys_HasWarnOptions
(
void
)
PYSTON_NOEXCEPT
;
// Pyston change: add this API to get sys modules dict
PyAPI_FUNC
(
PyObject
*
)
PySys_GetModulesDict
(
void
)
PYSTON_NOEXCEPT
;
#ifdef __cplusplus
}
#endif
...
...
from_cpython/Include/warnings.h
View file @
45458e12
...
...
@@ -6,7 +6,7 @@
extern
"C"
{
#endif
PyAPI_FUNC
(
void
)
_PyWarnings_Init
(
void
)
PYSTON_NOEXCEPT
;
void
_PyWarnings_Init
(
void
)
;
PyAPI_FUNC
(
int
)
PyErr_WarnEx
(
PyObject
*
,
const
char
*
,
Py_ssize_t
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PyErr_WarnExplicit
(
PyObject
*
,
const
char
*
,
const
char
*
,
int
,
...
...
from_cpython/Python/_warnings.c
View file @
45458e12
...
...
@@ -280,8 +280,10 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
PyFile_WriteString
(
"
\n
"
,
f_stderr
);
}
else
_Py_DisplaySourceLine
(
f_stderr
,
PyString_AS_STRING
(
filename
),
lineno
,
2
);
// Pyston change: not implemented, comment this out
// This should implemented with Pyston traceback.
/* _Py_DisplaySourceLine(f_stderr, PyString_AS_STRING(filename), */
/* lineno, 2); */
PyErr_Clear
();
}
...
...
@@ -446,24 +448,21 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
PyObject
*
globals
;
/* Setup globals and lineno. */
PyFrameObject
*
f
=
PyThreadState_GET
()
->
frame
;
while
(
--
stack_level
>
0
&&
f
!=
NULL
)
f
=
f
->
f_back
;
if
(
f
==
NULL
)
{
globals
=
PyThreadState_Get
()
->
interp
->
sysdict
;
// Pyston changes: use Pyston's BoxedFrame to get globals and lineno.
PyObject
*
frame
=
PyFrame_ForStackLevel
(
stack_level
);
if
(
!
frame
)
{
globals
=
PySys_GetModulesDict
();
*
lineno
=
1
;
}
else
{
globals
=
f
->
f_globals
;
*
lineno
=
PyFrame_GetLineNumber
(
f
);
}
else
{
globals
=
PyFrame_GetGlobals
(
frame
);
*
lineno
=
PyFrame_GetLineNumber
(
frame
);
}
*
module
=
NULL
;
/* Setup registry. */
assert
(
globals
!=
NULL
);
assert
(
PyDict_Check
(
globals
));
/* assert(PyDict_Check(globals)); */
*
registry
=
PyDict_GetItemString
(
globals
,
"__warningregistry__"
);
if
(
*
registry
==
NULL
)
{
int
rc
;
...
...
@@ -905,6 +904,7 @@ _PyWarnings_Init(void)
_default_action
=
PyString_FromString
(
"default"
);
if
(
_default_action
==
NULL
)
return
;
Py_INCREF
(
_default_action
);
if
(
PyModule_AddObject
(
m
,
"default_action"
,
_default_action
)
<
0
)
return
;
}
src/runtime/builtin_modules/sys.cpp
View file @
45458e12
...
...
@@ -41,6 +41,7 @@ BoxedDict* sys_modules_dict;
extern
"C"
{
// supposed to be exposed through sys.flags
int
Py_BytesWarningFlag
=
0
;
int
Py_DivisionWarningFlag
=
0
;
int
Py_HashRandomizationFlag
=
0
;
}
...
...
@@ -400,6 +401,10 @@ extern "C" const char* Py_GetPlatform() noexcept {
#endif
}
extern
"C"
PyObject
*
PySys_GetModulesDict
()
noexcept
{
return
getSysModulesDict
();
}
static
PyObject
*
sys_excepthook
(
PyObject
*
self
,
PyObject
*
args
)
noexcept
{
PyObject
*
exc
,
*
value
,
*
tb
;
if
(
!
PyArg_UnpackTuple
(
args
,
"excepthook"
,
3
,
3
,
&
exc
,
&
value
,
&
tb
))
...
...
src/runtime/capi.cpp
View file @
45458e12
...
...
@@ -585,8 +585,11 @@ extern "C" int PyObject_IsTrue(PyObject* o) noexcept {
extern
"C"
int
PyObject_Not
(
PyObject
*
o
)
noexcept
{
fatalOrError
(
PyExc_NotImplementedError
,
"unimplemented"
);
return
-
1
;
int
res
;
res
=
PyObject_IsTrue
(
o
);
if
(
res
<
0
)
return
res
;
return
res
==
0
;
}
extern
"C"
PyObject
*
PyObject_Call
(
PyObject
*
callable_object
,
PyObject
*
args
,
PyObject
*
kw
)
noexcept
{
...
...
@@ -1034,16 +1037,6 @@ extern "C" PyObject* PyErr_Occurred() noexcept {
return
cur_thread_state
.
curexc_type
;
}
extern
"C"
int
PyErr_WarnEx
(
PyObject
*
category
,
const
char
*
text
,
Py_ssize_t
stacklevel
)
noexcept
{
// These warnings are silenced by default:
// We should copy the real CPython code in here
if
(
category
==
PyExc_DeprecationWarning
)
return
0
;
fatalOrError
(
PyExc_NotImplementedError
,
"unimplemented"
);
return
-
1
;
}
extern
"C"
void
*
PyObject_Malloc
(
size_t
sz
)
noexcept
{
return
gc_compat_malloc
(
sz
);
}
...
...
@@ -1924,13 +1917,6 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
return
rtn
;
}
/* Warning with explicit origin */
extern
"C"
int
PyErr_WarnExplicit
(
PyObject
*
category
,
const
char
*
text
,
const
char
*
filename_str
,
int
lineno
,
const
char
*
module_str
,
PyObject
*
registry
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
}
/* extension modules might be compiled with GC support so these
functions must always be available */
...
...
src/runtime/frame.cpp
View file @
45458e12
...
...
@@ -158,6 +158,10 @@ extern "C" PyObject* PyFrame_GetGlobals(Box* f) {
return
BoxedFrame
::
globals
(
f
,
NULL
);
}
extern
"C"
PyObject
*
PyFrame_ForStackLevel
(
int
stack_level
)
{
return
getFrame
(
stack_level
);
}
void
setupFrame
()
{
frame_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedFrame
::
gchandler
,
0
,
0
,
sizeof
(
BoxedFrame
),
false
,
"frame"
);
...
...
src/runtime/types.cpp
View file @
45458e12
...
...
@@ -77,6 +77,7 @@ extern "C" void initzlib();
extern
"C"
void
init_codecs
();
extern
"C"
void
init_socket
();
extern
"C"
void
_PyUnicode_Init
();
extern
"C"
void
_PyWarnings_Init
();
extern
"C"
void
_string_init
();
extern
"C"
void
initunicodedata
();
extern
"C"
void
init_weakref
();
...
...
@@ -3937,6 +3938,7 @@ void setupRuntime() {
setupClassobj
();
setupSuper
();
_PyUnicode_Init
();
_PyWarnings_Init
();
_string_init
();
setupDescr
();
setupTraceback
();
...
...
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