This commit is contained in:
blueloveTH 2024-08-05 17:11:53 +08:00
parent 0918256c90
commit 4e8920b280
2 changed files with 2 additions and 4 deletions

View File

@ -295,8 +295,6 @@ bool py_matchexc(py_Type type);
/// Clear the current exception.
void py_clearexc(py_StackRef p0);
#define IOError(...) py_exception(tp_IOError, __VA_ARGS__)
#define OSError(...) py_exception(tp_OSError, __VA_ARGS__)
#define NameError(n) py_exception(tp_NameError, "name '%n' is not defined", (n))
#define TypeError(...) py_exception(tp_TypeError, __VA_ARGS__)
#define RuntimeError(...) py_exception(tp_RuntimeError, __VA_ARGS__)

View File

@ -31,13 +31,13 @@ static bool os_chdir(int argc, py_Ref argv) {
PY_CHECK_ARG_TYPE(0, tp_str);
const char* path = py_tostr(py_arg(0));
int code = platform_chdir(path);
if(code != 0) return OSError("chdir() failed: %d", code);
if(code != 0) return py_exception(tp_OSError, "chdir() failed: %d", code);
return true;
}
static bool os_getcwd(int argc, py_Ref argv) {
char buf[1024];
if(!platform_getcwd(buf, sizeof(buf))) return OSError("getcwd() failed");
if(!platform_getcwd(buf, sizeof(buf))) return py_exception(tp_OSError, "getcwd() failed");
py_newstr(py_retval(), buf);
return true;
}