Commit cd9f3a0f authored by Michael Arntzenius's avatar Michael Arntzenius

add switch to turn some fatal errors into python exceptions

parent dd25db82
......@@ -28,7 +28,8 @@
namespace pyston {
extern "C" Py_ssize_t _PyObject_LengthHint(PyObject* o, Py_ssize_t defaultvalue) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
static int _IsFortranContiguous(Py_buffer* view) {
......@@ -147,10 +148,11 @@ extern "C" int PyBuffer_FillInfo(Py_buffer* view, PyObject* obj, void* buf, Py_s
if (view == NULL)
return 0;
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) && (readonly == 1)) {
// Don't support PyErr_SetString yet:
assert(0);
// PyErr_SetString(PyExc_BufferError, "Object is not writable.");
// return -1;
// https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_FillInfo
// '[On failure], raise PyExc_BufferError, set view->obj to NULL and return -1'
view->obj = NULL;
PyErr_SetString(PyExc_BufferError, "Object is not writable.");
return -1;
}
view->obj = obj;
......@@ -467,7 +469,8 @@ extern "C" PyObject* PyObject_CallObject(PyObject* obj, PyObject* args) noexcept
r = runtimeCall(obj, ArgPassSpec(0, 0, false, false), NULL, NULL, NULL, NULL, NULL);
return r;
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -498,7 +501,8 @@ extern "C" int PyObject_AsCharBuffer(PyObject* obj, const char** buffer, Py_ssiz
}
extern "C" int PyObject_AsReadBuffer(PyObject* obj, const void** buffer, Py_ssize_t* buffer_len) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
static PyObject* call_function_tail(PyObject* callable, PyObject* args) {
......@@ -1155,19 +1159,23 @@ extern "C" Py_ssize_t PyMapping_Size(PyObject* o) noexcept {
}
extern "C" int PyMapping_HasKeyString(PyObject* o, char* key) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PyMapping_HasKey(PyObject* o, PyObject* key) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* PyMapping_GetItemString(PyObject* o, char* key) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" int PyMapping_SetItemString(PyObject* o, char* key, PyObject* v) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PyNumber_Check(PyObject* obj) noexcept {
......@@ -1194,7 +1202,8 @@ extern "C" PyObject* PyNumber_Subtract(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::Sub);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -1202,7 +1211,8 @@ extern "C" PyObject* PyNumber_Multiply(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::Mult);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -1210,12 +1220,14 @@ extern "C" PyObject* PyNumber_Divide(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::Div);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
extern "C" PyObject* PyNumber_FloorDivide(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_TrueDivide(PyObject* lhs, PyObject* rhs) noexcept {
......@@ -1231,7 +1243,8 @@ extern "C" PyObject* PyNumber_Remainder(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::Mod);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -1239,43 +1252,51 @@ extern "C" PyObject* PyNumber_Divmod(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::DivMod);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
extern "C" PyObject* PyNumber_Power(PyObject*, PyObject*, PyObject* o3) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Negative(PyObject* o) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Positive(PyObject* o) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Absolute(PyObject* o) noexcept {
try {
return abs_(o);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
extern "C" PyObject* PyNumber_Invert(PyObject* o) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Lshift(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Rshift(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::RShift);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -1283,76 +1304,94 @@ extern "C" PyObject* PyNumber_And(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::BitAnd);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
extern "C" PyObject* PyNumber_Xor(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Or(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceAdd(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceSubtract(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceMultiply(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceDivide(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceFloorDivide(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceTrueDivide(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceRemainder(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlacePower(PyObject*, PyObject*, PyObject* o3) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceLshift(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceRshift(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceAnd(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceXor(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_InPlaceOr(PyObject*, PyObject*) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" int PyNumber_Coerce(PyObject**, PyObject**) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PyNumber_CoerceEx(PyObject**, PyObject**) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* _PyNumber_ConvertIntegralToInt(PyObject* integral, const char* error_format) noexcept {
......@@ -1383,7 +1422,8 @@ extern "C" PyObject* _PyNumber_ConvertIntegralToInt(PyObject* integral, const ch
non_integral_error:
if (PyInstance_Check(integral)) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
/* cpython has this:
type_name = PyString_AS_STRING(((PyInstanceObject *)integral)
->in_class->cl_name);
......@@ -1437,7 +1477,9 @@ extern "C" PyObject* PyNumber_Int(PyObject* o) noexcept {
PyErr_Clear(); /* It's not an error if o.__trunc__ doesn't exist. */
// the remainder of PyNumber_Int deals with converting from unicode/string to int
Py_FatalError("unimplemented string -> int conversion");
fatalOrError(PyExc_NotImplementedError, "unimplemented string -> int conversion");
return nullptr;
#if 0
if (PyString_Check(o))
return int_from_string(PyString_AS_STRING(o),
......@@ -1465,11 +1507,13 @@ extern "C" PyObject* PyNumber_Long(PyObject* o) noexcept {
if (o->cls == float_cls)
return PyLong_FromDouble(PyFloat_AsDouble(o));
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Float(PyObject* o) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_Index(PyObject* o) noexcept {
......@@ -1480,11 +1524,13 @@ extern "C" PyObject* PyNumber_Index(PyObject* o) noexcept {
return o;
}
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyNumber_ToBase(PyObject* n, int base) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" Py_ssize_t PyNumber_AsSsize_t(PyObject* o, PyObject* exc) noexcept {
......
......@@ -499,7 +499,8 @@ extern "C" int PyObject_RichCompareBool(PyObject* v, PyObject* w, int op) noexce
// I'm not sure how we can support this one:
extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
/* These methods are used to control infinite recursion in repr, str, print,
......@@ -564,6 +565,9 @@ extern "C" void Py_ReprLeave(PyObject* obj) noexcept {
}
extern "C" int PyObject_Compare(PyObject* o1, PyObject* o2) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
// 'On error, the value returned is undefined; use PyErr_Occurred() to detect an error.'
// - https://docs.python.org/2/c-api/object.html
return 0xdeadbeef;
}
}
......@@ -29,6 +29,7 @@ int PYTHON_VERSION_HEX = version_hex(PYTHON_VERSION_MAJOR, PYTHON_VERSION_MINOR,
int MAX_OPT_ITERATIONS = 1;
bool CONTINUE_AFTER_FATAL = false;
bool FORCE_INTERPRETER = false;
bool FORCE_OPTIMIZE = false;
bool SHOW_DISASM = false;
......
......@@ -37,7 +37,7 @@ extern int OSR_THRESHOLD_T2, REOPT_THRESHOLD_T2;
extern int SPECULATION_THRESHOLD;
extern bool SHOW_DISASM, FORCE_INTERPRETER, FORCE_OPTIMIZE, PROFILE, DUMPJIT, TRAP, USE_STRIPPED_STDLIB,
ENABLE_INTERPRETER, ENABLE_PYPA_PARSER, USE_REGALLOC_BASIC;
CONTINUE_AFTER_FATAL, ENABLE_INTERPRETER, ENABLE_PYPA_PARSER, USE_REGALLOC_BASIC;
extern bool ENABLE_ICS, ENABLE_ICGENERICS, ENABLE_ICGETITEMS, ENABLE_ICSETITEMS, ENABLE_ICDELITEMS, ENABLE_ICBINEXPS,
ENABLE_ICNONZEROS, ENABLE_ICCALLSITES, ENABLE_ICSETATTRS, ENABLE_ICGETATTRS, ENALBE_ICDELATTRS, ENABLE_ICGETGLOBALS,
......
......@@ -79,7 +79,7 @@ static int main(int argc, char** argv) {
bool force_repl = false;
bool stats = false;
const char* command = NULL;
while ((code = getopt(argc, argv, "+OqdIibpjtrsSvnxc:")) != -1) {
while ((code = getopt(argc, argv, "+OqdIibpjtrsSvnxc:F")) != -1) {
if (code == 'O')
FORCE_OPTIMIZE = true;
else if (code == 't')
......@@ -110,6 +110,8 @@ static int main(int argc, char** argv) {
USE_REGALLOC_BASIC = false;
} else if (code == 'x') {
ENABLE_PYPA_PARSER = false;
} else if (code == 'F') {
CONTINUE_AFTER_FATAL = true;
} else if (code == 'c') {
command = optarg;
// no more option parsing; the rest of our arguments go into sys.argv.
......
......@@ -945,7 +945,8 @@ Box* rawInput(Box* prompt) {
}
Box* input(Box* prompt) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
Box* builtinRound(Box* _number, Box* _ndigits) {
......@@ -961,11 +962,13 @@ Box* builtinRound(Box* _number, Box* _ndigits) {
return boxFloat(round(number->d));
}
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
Box* builtinCmp(Box* lhs, Box* rhs) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
void setupBuiltins() {
......
......@@ -266,12 +266,14 @@ extern "C" PyObject* PyObject_GenericGetAttr(PyObject* o, PyObject* name) noexce
}
extern "C" PyObject* _PyObject_GenericGetAttrWithDict(PyObject* obj, PyObject* name, PyObject* dict) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" int _PyObject_GenericSetAttrWithDict(PyObject* obj, PyObject* name, PyObject* value,
PyObject* dict) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
......@@ -295,7 +297,8 @@ extern "C" int PyObject_SetItem(PyObject* o, PyObject* key, PyObject* v) noexcep
}
extern "C" int PyObject_DelItem(PyObject* o, PyObject* key) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* PyObject_RichCompare(PyObject* o1, PyObject* o2, int opid) noexcept {
......@@ -320,7 +323,8 @@ extern "C" PyObject* PyObject_RichCompare(PyObject* o1, PyObject* o2, int opid)
translated_op = AST_TYPE::GtE;
break;
default:
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
};
try {
......@@ -339,7 +343,8 @@ extern "C" long PyObject_Hash(PyObject* o) noexcept {
try {
return hash(o)->n;
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
}
......@@ -369,13 +374,15 @@ extern "C" int PyObject_IsTrue(PyObject* o) noexcept {
try {
return nonzero(o);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
}
extern "C" int PyObject_Not(PyObject* o) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* PyObject_Call(PyObject* callable_object, PyObject* args, PyObject* kw) noexcept {
......@@ -449,15 +456,18 @@ extern "C" int PyObject_Print(PyObject* obj, FILE* fp, int flags) noexcept {
};
extern "C" PyObject* PySequence_Repeat(PyObject* o, Py_ssize_t count) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PySequence_InPlaceConcat(PyObject* o1, PyObject* o2) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PySequence_InPlaceRepeat(PyObject* o, Py_ssize_t count) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PySequence_GetItem(PyObject* o, Py_ssize_t i) noexcept {
......@@ -475,32 +485,39 @@ extern "C" PyObject* PySequence_GetSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t
// Not sure if this is really the same:
return getitem(o, createSlice(boxInt(i1), boxInt(i2), None));
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
extern "C" int PySequence_SetItem(PyObject* o, Py_ssize_t i, PyObject* v) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PySequence_DelItem(PyObject* o, Py_ssize_t i) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PySequence_SetSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t i2, PyObject* v) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" int PySequence_DelSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t i2) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" Py_ssize_t PySequence_Count(PyObject* o, PyObject* value) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" Py_ssize_t PySequence_Index(PyObject* o, PyObject* value) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* PySequence_Tuple(PyObject* o) noexcept {
......@@ -509,7 +526,8 @@ extern "C" PyObject* PySequence_Tuple(PyObject* o) noexcept {
if (PyList_Check(o))
return PyList_AsTuple(o);
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" PyObject* PyIter_Next(PyObject* iter) noexcept {
......@@ -746,7 +764,8 @@ extern "C" int PyErr_BadArgument() noexcept {
}
extern "C" PyObject* PyErr_NoMemory() noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
extern "C" int PyExceptionClass_Check(PyObject* o) noexcept {
......@@ -871,7 +890,8 @@ extern "C" int PyErr_WarnEx(PyObject* category, const char* text, Py_ssize_t sta
if (category == PyExc_DeprecationWarning)
return 0;
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* PyImport_Import(PyObject* module_name) noexcept {
......@@ -882,7 +902,8 @@ extern "C" PyObject* PyImport_Import(PyObject* module_name) noexcept {
std::string _module_name = static_cast<BoxedString*>(module_name)->s;
return importModuleLevel(_module_name, None, None, -1);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
}
......@@ -1125,7 +1146,8 @@ extern "C" PyOS_sighandler_t PyOS_setsig(int sig, PyOS_sighandler_t handler) noe
}
extern "C" int Py_AddPendingCall(int (*func)(void*), void* arg) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return -1;
}
extern "C" PyObject* _PyImport_FixupExtension(char* name, char* filename) noexcept {
......@@ -1135,7 +1157,8 @@ extern "C" PyObject* _PyImport_FixupExtension(char* name, char* filename) noexce
}
extern "C" PyObject* _PyImport_FindExtension(char* name, char* filename) noexcept {
Py_FatalError("unimplemented");
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
}
static PyObject* listmethodchain(PyMethodChain* chain) noexcept {
......@@ -1352,4 +1375,11 @@ void setupCAPI() {
void teardownCAPI() {
}
void fatalOrError(PyObject* exception, const char* message) noexcept {
if (CONTINUE_AFTER_FATAL)
PyErr_SetString(exception, message);
else
Py_FatalError(message);
}
}
......@@ -19,6 +19,7 @@
namespace pyston {
class Box;
class BoxedModule;
BoxedModule* importTestExtension(const std::string&);
......@@ -26,6 +27,9 @@ void checkAndThrowCAPIException();
void throwCAPIException() __attribute__((noreturn));
struct ExcInfo;
void setCAPIException(const ExcInfo& e);
// TODO: not sure whether this belongs here
void fatalOrError(Box* object, const char* message) noexcept;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment