|
|
@ -61,7 +61,8 @@ long heap_size = 1024*1024 * (sizeof(mp_uint_t) / 4); |
|
|
|
|
|
|
|
STATIC void stderr_print_strn(void *env, const char *str, mp_uint_t len) { |
|
|
|
(void)env; |
|
|
|
fwrite(str, len, 1, stderr); |
|
|
|
ssize_t dummy = write(STDERR_FILENO, str, len); |
|
|
|
(void)dummy; |
|
|
|
} |
|
|
|
|
|
|
|
const mp_print_t mp_stderr_print = {NULL, stderr_print_strn}; |
|
|
@ -84,6 +85,7 @@ STATIC int handle_uncaught_exception(mp_obj_t exc) { |
|
|
|
|
|
|
|
// Report all other exceptions
|
|
|
|
mp_obj_print_exception(&mp_stderr_print, exc); |
|
|
|
mp_printf(&mp_stderr_print, exc); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
@ -492,7 +494,7 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
if (mp_obj_is_package(mod)) { |
|
|
|
// TODO
|
|
|
|
fprintf(stderr, "%s: -m for packages not yet implemented\n", argv[0]); |
|
|
|
mp_printf(&mp_stderr_print, "%s: -m for packages not yet implemented\n", argv[0]); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
ret = 0; |
|
|
@ -515,7 +517,7 @@ int main(int argc, char **argv) { |
|
|
|
char *pathbuf = malloc(PATH_MAX); |
|
|
|
char *basedir = realpath(argv[a], pathbuf); |
|
|
|
if (basedir == NULL) { |
|
|
|
fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[a], errno); |
|
|
|
mp_printf(&mp_stderr_print, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[a], errno); |
|
|
|
perror(""); |
|
|
|
// CPython exits with 2 in such case
|
|
|
|
ret = 2; |
|
|
@ -577,7 +579,7 @@ uint mp_import_stat(const char *path) { |
|
|
|
int DEBUG_printf(const char *fmt, ...) { |
|
|
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
|
|
int ret = vfprintf(stderr, fmt, ap); |
|
|
|
int ret = mp_vprintf(&mp_stderr_print, fmt, ap); |
|
|
|
va_end(ap); |
|
|
|
return ret; |
|
|
|
} |
|
|
|