mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
...
This commit is contained in:
parent
0918256c90
commit
4e8920b280
@ -295,8 +295,6 @@ bool py_matchexc(py_Type type);
|
|||||||
/// Clear the current exception.
|
/// Clear the current exception.
|
||||||
void py_clearexc(py_StackRef p0);
|
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 NameError(n) py_exception(tp_NameError, "name '%n' is not defined", (n))
|
||||||
#define TypeError(...) py_exception(tp_TypeError, __VA_ARGS__)
|
#define TypeError(...) py_exception(tp_TypeError, __VA_ARGS__)
|
||||||
#define RuntimeError(...) py_exception(tp_RuntimeError, __VA_ARGS__)
|
#define RuntimeError(...) py_exception(tp_RuntimeError, __VA_ARGS__)
|
||||||
|
@ -31,13 +31,13 @@ static bool os_chdir(int argc, py_Ref argv) {
|
|||||||
PY_CHECK_ARG_TYPE(0, tp_str);
|
PY_CHECK_ARG_TYPE(0, tp_str);
|
||||||
const char* path = py_tostr(py_arg(0));
|
const char* path = py_tostr(py_arg(0));
|
||||||
int code = platform_chdir(path);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool os_getcwd(int argc, py_Ref argv) {
|
static bool os_getcwd(int argc, py_Ref argv) {
|
||||||
char buf[1024];
|
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);
|
py_newstr(py_retval(), buf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user