mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 11:40:18 +01:00
py: Include filename in errors from loading/saving files via "open".
This improves error messages in mpy-cross: - When loading a .py file that doesn't exist (or can't be opened) it now includes the filename in the OSError. - When saving a .mpy file that can't be opened it now raises an exception (prior, it would silently fail), and includes the filename in the OSError. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -139,7 +139,7 @@ void mp_reader_new_file(mp_reader_t *reader, const char *filename) {
|
||||
int fd = open(filename, O_RDONLY, 0644);
|
||||
MP_THREAD_GIL_ENTER();
|
||||
if (fd < 0) {
|
||||
mp_raise_OSError(errno);
|
||||
mp_raise_OSError_with_filename(errno, filename);
|
||||
}
|
||||
mp_reader_new_file_from_fd(reader, fd, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user