extern "C" void raise3_capi(Box* arg0, Box* arg1, Box* arg2) noexcept { bool reraise = arg2 != NULL && arg2 != None; ExcInfo exc_info(NULL, NULL, NULL); try { exc_info = excInfoForRaise(arg0, arg1, arg2); } catch (ExcInfo e) { exc_info = e; } if (reraise) startReraise(); PyErr_Restore(exc_info.type, exc_info.value, exc_info.traceback); }
void prependToSysPath(llvm::StringRef path) { BoxedList* sys_path = getSysPath(); static BoxedString* insert_str = getStaticString("insert"); CallattrFlags callattr_flags{.cls_only = false, .null_on_nonexistent = false, .argspec = ArgPassSpec(2) }; autoDecref(callattr(sys_path, insert_str, callattr_flags, autoDecref(boxInt(0)), autoDecref(boxString(path)), NULL, NULL, NULL)); } static BoxedClass* sys_flags_cls; class BoxedSysFlags : public Box { public: Box* division_warning, *bytes_warning, *no_user_site, *optimize; BoxedSysFlags() { auto zero = boxInt(0); assert(zero); division_warning = incref(zero); bytes_warning = incref(zero); no_user_site = incref(zero); optimize = incref(zero); Py_DECREF(zero); } DEFAULT_CLASS(sys_flags_cls); static Box* __new__(Box* cls, Box* args, Box* kwargs) { raiseExcHelper(TypeError, "cannot create 'sys.flags' instances"); } static void dealloc(BoxedSysFlags* self) { Py_DECREF(self->division_warning); Py_DECREF(self->bytes_warning); Py_DECREF(self->no_user_site); Py_DECREF(self->optimize); } }; static std::string generateVersionString() { std::ostringstream oss; oss << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << '.' << PY_MICRO_VERSION; oss << '\n'; oss << "[Pyston " << PYSTON_VERSION_MAJOR << '.' << PYSTON_VERSION_MINOR << '.' << PYSTON_VERSION_MICRO << "]"; return oss.str(); }
if (PyErr_Occurred()) { Py_CLEAR(floatinfo); return NULL; } return floatinfo; } PyDoc_STRVAR(exc_info_doc, "exc_info() -> (type, value, traceback)\n\ \n\ Return information about the most recent exception caught by an except\n\ clause in the current stack frame or in an older stack frame."); PyDoc_STRVAR(exc_clear_doc, "exc_clear() -> None\n\ \n\ Clear global information on the current exception. Subsequent calls to\n\ exc_info() will return (None,None,None) until another exception is raised\n\ in the current thread or the execution stack returns to a frame where\n\ another exception is being handled."); PyDoc_STRVAR(exit_doc, "exit([status])\n\ \n\ Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ If the status is an integer, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."); PyDoc_STRVAR(getdefaultencoding_doc, "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\