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
cfb1045a
Commit
cfb1045a
authored
Jan 08, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more CPython code
parent
c7c10250
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
130 additions
and
10 deletions
+130
-10
from_cpython/Include/pyerrors.h
from_cpython/Include/pyerrors.h
+3
-4
src/capi/errors.cpp
src/capi/errors.cpp
+1
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+9
-0
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+11
-2
src/runtime/capi.cpp
src/runtime/capi.cpp
+102
-3
src/runtime/file.cpp
src/runtime/file.cpp
+4
-1
No files found.
from_cpython/Include/pyerrors.h
View file @
cfb1045a
...
...
@@ -219,10 +219,9 @@ PyAPI_DATA(PyTypeObject *) VMSError;
#define PyExc_BufferError ((PyObject*)BufferError)
PyAPI_DATA
(
PyTypeObject
*
)
BufferError
;
#define PyExc_MemoryErrorInst ((PyObject*)MemoryErrorInst)
PyAPI_DATA
(
PyTypeObject
*
)
MemoryErrorInst
;
#define PyExc_RecursionErrorInst ((PyObject*)RecursionErrorInst)
PyAPI_DATA
(
PyTypeObject
*
)
RecursionErrorInst
;
PyAPI_DATA
(
PyObject
*
)
PyExc_MemoryErrorInst
;
PyAPI_DATA
(
PyObject
*
)
PyExc_RecursionErrorInst
;
/* Predefined warning categories */
#define PyExc_Warning ((PyObject*)Warning)
...
...
src/capi/errors.cpp
View file @
cfb1045a
...
...
@@ -181,6 +181,7 @@ extern "C" void PyErr_WriteUnraisable(PyObject* obj) {
Py_XDECREF
(
v
);
Py_XDECREF
(
tb
);
}
extern
"C"
void
PyErr_Display
(
PyObject
*
exception
,
PyObject
*
value
,
PyObject
*
tb
)
{
Py_FatalError
(
"unimplemented"
);
}
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
cfb1045a
...
...
@@ -521,6 +521,9 @@ BoxedClass* BaseException, *Exception, *StandardError, *AssertionError, *Attribu
*
RuntimeError
,
*
ImportError
,
*
StopIteration
,
*
Warning
,
*
SyntaxError
,
*
OverflowError
,
*
DeprecationWarning
,
*
MemoryError
,
*
LookupError
,
*
EnvironmentError
,
*
ArithmeticError
,
*
BufferError
,
*
KeyboardInterrupt
,
*
SystemExit
,
*
SystemError
,
*
NotImplementedError
,
*
PendingDeprecationWarning
;
Box
*
PyExc_RecursionErrorInst
;
Box
*
PyExc_MemoryErrorInst
;
}
Box
*
exceptionNew1
(
BoxedClass
*
cls
)
{
...
...
@@ -1086,5 +1089,11 @@ void setupBuiltins() {
builtins_module
->
giveAttr
(
"property"
,
property_cls
);
builtins_module
->
giveAttr
(
"staticmethod"
,
staticmethod_cls
);
builtins_module
->
giveAttr
(
"classmethod"
,
classmethod_cls
);
PyExc_RecursionErrorInst
=
new
BoxedException
(
RuntimeError
);
gc
::
registerPermanentRoot
(
PyExc_RecursionErrorInst
);
PyExc_MemoryErrorInst
=
new
BoxedException
(
MemoryError
);
gc
::
registerPermanentRoot
(
PyExc_MemoryErrorInst
);
}
}
src/runtime/builtin_modules/sys.cpp
View file @
cfb1045a
...
...
@@ -76,11 +76,20 @@ Box* getSysStdout() {
}
extern
"C"
int
PySys_SetObject
(
const
char
*
name
,
PyObject
*
v
)
{
Py_FatalError
(
"unimplemented"
);
try
{
if
(
!
v
)
{
if
(
sys_module
->
getattr
(
name
))
sys_module
->
delattr
(
name
,
NULL
);
}
else
sys_module
->
setattr
(
name
,
v
,
NULL
);
}
catch
(
Box
*
b
)
{
abort
();
}
return
0
;
}
extern
"C"
PyObject
*
PySys_GetObject
(
const
char
*
name
)
{
Py_FatalError
(
"unimplemented"
);
return
sys_module
->
getattr
(
name
);
}
static
void
mywrite
(
const
char
*
name
,
FILE
*
fp
,
const
char
*
format
,
va_list
va
)
noexcept
{
...
...
src/runtime/capi.cpp
View file @
cfb1045a
...
...
@@ -22,6 +22,7 @@
#include "capi/types.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/classobj.h"
#include "runtime/import.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
@@ -643,7 +644,101 @@ extern "C" int Py_FlushLine(void) {
}
extern
"C"
void
PyErr_NormalizeException
(
PyObject
**
exc
,
PyObject
**
val
,
PyObject
**
tb
)
{
Py_FatalError
(
"unimplemented"
);
PyObject
*
type
=
*
exc
;
PyObject
*
value
=
*
val
;
PyObject
*
inclass
=
NULL
;
PyObject
*
initial_tb
=
NULL
;
PyThreadState
*
tstate
=
NULL
;
if
(
type
==
NULL
)
{
/* There was no exception, so nothing to do. */
return
;
}
/* If PyErr_SetNone() was used, the value will have been actually
set to NULL.
*/
if
(
!
value
)
{
value
=
Py_None
;
Py_INCREF
(
value
);
}
if
(
PyExceptionInstance_Check
(
value
))
inclass
=
PyExceptionInstance_Class
(
value
);
/* Normalize the exception so that if the type is a class, the
value will be an instance.
*/
if
(
PyExceptionClass_Check
(
type
))
{
/* if the value was not an instance, or is not an instance
whose class is (or is derived from) type, then use the
value as an argument to instantiation of the type
class.
*/
if
(
!
inclass
||
!
PyObject_IsSubclass
(
inclass
,
type
))
{
PyObject
*
args
,
*
res
;
if
(
value
==
Py_None
)
args
=
PyTuple_New
(
0
);
else
if
(
PyTuple_Check
(
value
))
{
Py_INCREF
(
value
);
args
=
value
;
}
else
args
=
PyTuple_Pack
(
1
,
value
);
if
(
args
==
NULL
)
goto
finally
;
res
=
PyEval_CallObject
(
type
,
args
);
Py_DECREF
(
args
);
if
(
res
==
NULL
)
goto
finally
;
Py_DECREF
(
value
);
value
=
res
;
}
/* if the class of the instance doesn't exactly match the
class of the type, believe the instance
*/
else
if
(
inclass
!=
type
)
{
Py_DECREF
(
type
);
type
=
inclass
;
Py_INCREF
(
type
);
}
}
*
exc
=
type
;
*
val
=
value
;
return
;
finally:
Py_DECREF
(
type
);
Py_DECREF
(
value
);
/* If the new exception doesn't set a traceback and the old
exception had a traceback, use the old traceback for the
new exception. It's better than nothing.
*/
initial_tb
=
*
tb
;
PyErr_Fetch
(
exc
,
val
,
tb
);
if
(
initial_tb
!=
NULL
)
{
if
(
*
tb
==
NULL
)
*
tb
=
initial_tb
;
else
Py_DECREF
(
initial_tb
);
}
/* normalize recursively */
tstate
=
PyThreadState_GET
();
if
(
++
tstate
->
recursion_depth
>
Py_GetRecursionLimit
())
{
--
tstate
->
recursion_depth
;
/* throw away the old exception... */
Py_DECREF
(
*
exc
);
Py_DECREF
(
*
val
);
/* ... and use the recursion error instead */
*
exc
=
PyExc_RuntimeError
;
*
val
=
PyExc_RecursionErrorInst
;
Py_INCREF
(
*
exc
);
Py_INCREF
(
*
val
);
/* just keeping the old traceback */
return
;
}
PyErr_NormalizeException
(
exc
,
val
,
tb
);
--
tstate
->
recursion_depth
;
}
void
checkAndThrowCAPIException
()
{
...
...
@@ -705,11 +800,11 @@ extern "C" int PyErr_CheckSignals() {
}
extern
"C"
int
PyExceptionClass_Check
(
PyObject
*
o
)
{
Py_FatalError
(
"unimplemented"
);
return
PyClass_Check
(
o
)
||
(
PyType_Check
(
o
)
&&
isSubclass
(
static_cast
<
BoxedClass
*>
(
o
),
BaseException
)
);
}
extern
"C"
int
PyExceptionInstance_Check
(
PyObject
*
o
)
{
Py_FatalError
(
"unimplemented"
);
return
PyInstance_Check
(
o
)
||
isSubclass
(
o
->
cls
,
BaseException
);
}
extern
"C"
const
char
*
PyExceptionClass_Name
(
PyObject
*
o
)
{
...
...
@@ -717,6 +812,10 @@ extern "C" const char* PyExceptionClass_Name(PyObject* o) {
}
extern
"C"
PyObject
*
PyExceptionInstance_Class
(
PyObject
*
o
)
{
return
PyInstance_Check
(
o
)
?
(
Box
*
)
static_cast
<
BoxedInstance
*>
(
o
)
->
inst_cls
:
o
->
cls
;
}
extern
"C"
int
PyTraceBack_Print
(
PyObject
*
v
,
PyObject
*
f
)
{
Py_FatalError
(
"unimplemented"
);
}
...
...
src/runtime/file.cpp
View file @
cfb1045a
...
...
@@ -192,7 +192,10 @@ extern "C" PyObject* PyFile_FromFile(FILE* fp, char* name, char* mode, int (*clo
}
extern
"C"
FILE
*
PyFile_AsFile
(
PyObject
*
f
)
{
Py_FatalError
(
"unimplemented"
);
if
(
!
f
||
!
PyFile_Check
(
f
))
return
NULL
;
return
static_cast
<
BoxedFile
*>
(
f
)
->
f
;
}
extern
"C"
int
PyFile_WriteObject
(
PyObject
*
v
,
PyObject
*
f
,
int
flags
)
{
...
...
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