all: Remove MICROPY_PY_IO_FILEIO config option.

Since commit e65d1e69e8 there is no longer an
io.FileIO class, so this option is no longer needed.

This option also controlled whether or not files supported being opened in
binary mode (eg 'rb'), and could, if disabled, lead to confusion as to why
opening a file in binary mode silently did the wrong thing (it would just
open in text mode if MICROPY_PY_IO_FILEIO was disabled).

The various VFS implementations (POSIX, FAT, LFS) were the only places
where enabling this option made a difference, and in almost all cases where
one of these filesystems were enabled, MICROPY_PY_IO_FILEIO was also
enabled.  So it makes sense to just unconditionally enable this feature
(ability to open a file in binary mode) in all cases, and so just remove
this config option altogether.  That makes configuration simpler and means
binary file support always exists (and opening a file in binary mode is
arguably more fundamental than opening in text mode, so if anything should
be configurable then it should be the ability to open in text mode).

Signed-off-by: Damien George <damien@micropython.org>
pull/9066/head
Damien George 2022-08-18 11:54:17 +10:00
rodzic 237a393bec
commit 8f4c108025
17 zmienionych plików z 0 dodań i 31 usunięć

Wyświetl plik

@ -69,7 +69,6 @@
#define MICROPY_PY_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_PY_CMATH (0) #define MICROPY_PY_CMATH (0)
#define MICROPY_PY_IO (0) #define MICROPY_PY_IO (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_STRUCT (0) #define MICROPY_PY_STRUCT (0)
#define MICROPY_PY_SYS (1) #define MICROPY_PY_SYS (1)
#define MICROPY_PY_SYS_EXIT (0) #define MICROPY_PY_SYS_EXIT (0)

Wyświetl plik

@ -170,7 +170,6 @@ STATIC const mp_rom_map_elem_t vfs_fat_rawfile_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(vfs_fat_rawfile_locals_dict, vfs_fat_rawfile_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(vfs_fat_rawfile_locals_dict, vfs_fat_rawfile_locals_dict_table);
#if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = { STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = {
.read = file_obj_read, .read = file_obj_read,
.write = file_obj_write, .write = file_obj_write,
@ -186,7 +185,6 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
.protocol = &vfs_fat_fileio_stream_p, .protocol = &vfs_fat_fileio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_fat_rawfile_locals_dict, .locals_dict = (mp_obj_dict_t *)&vfs_fat_rawfile_locals_dict,
}; };
#endif
STATIC const mp_stream_p_t vfs_fat_textio_stream_p = { STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
.read = file_obj_read, .read = file_obj_read,
@ -230,11 +228,9 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
case '+': case '+':
mode |= FA_READ | FA_WRITE; mode |= FA_READ | FA_WRITE;
break; break;
#if MICROPY_PY_IO_FILEIO
case 'b': case 'b':
type = &mp_type_vfs_fat_fileio; type = &mp_type_vfs_fat_fileio;
break; break;
#endif
case 't': case 't':
type = &mp_type_vfs_fat_textio; type = &mp_type_vfs_fat_textio;
break; break;

Wyświetl plik

@ -68,11 +68,9 @@ mp_obj_t MP_VFS_LFSx(file_open)(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mod
case '+': case '+':
flags |= LFSx_MACRO(_O_RDWR); flags |= LFSx_MACRO(_O_RDWR);
break; break;
#if MICROPY_PY_IO_FILEIO
case 'b': case 'b':
type = &MP_TYPE_VFS_LFSx_(_fileio); type = &MP_TYPE_VFS_LFSx_(_fileio);
break; break;
#endif
case 't': case 't':
type = &MP_TYPE_VFS_LFSx_(_textio); type = &MP_TYPE_VFS_LFSx_(_textio);
break; break;
@ -216,7 +214,6 @@ STATIC const mp_rom_map_elem_t MP_VFS_LFSx(file_locals_dict_table)[] = {
}; };
STATIC MP_DEFINE_CONST_DICT(MP_VFS_LFSx(file_locals_dict), MP_VFS_LFSx(file_locals_dict_table)); STATIC MP_DEFINE_CONST_DICT(MP_VFS_LFSx(file_locals_dict), MP_VFS_LFSx(file_locals_dict_table));
#if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t MP_VFS_LFSx(fileio_stream_p) = { STATIC const mp_stream_p_t MP_VFS_LFSx(fileio_stream_p) = {
.read = MP_VFS_LFSx(file_read), .read = MP_VFS_LFSx(file_read),
.write = MP_VFS_LFSx(file_write), .write = MP_VFS_LFSx(file_write),
@ -232,7 +229,6 @@ const mp_obj_type_t MP_TYPE_VFS_LFSx_(_fileio) = {
.protocol = &MP_VFS_LFSx(fileio_stream_p), .protocol = &MP_VFS_LFSx(fileio_stream_p),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict), .locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
}; };
#endif
STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = { STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
.read = MP_VFS_LFSx(file_read), .read = MP_VFS_LFSx(file_read),

Wyświetl plik

@ -83,15 +83,12 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
case '+': case '+':
mode_rw = O_RDWR; mode_rw = O_RDWR;
break; break;
#if MICROPY_PY_IO_FILEIO
// If we don't have io.FileIO, then files are in text mode implicitly
case 'b': case 'b':
type = &mp_type_vfs_posix_fileio; type = &mp_type_vfs_posix_fileio;
break; break;
case 't': case 't':
type = &mp_type_vfs_posix_textio; type = &mp_type_vfs_posix_textio;
break; break;
#endif
} }
} }
@ -246,7 +243,6 @@ STATIC const mp_rom_map_elem_t vfs_posix_rawfile_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(vfs_posix_rawfile_locals_dict, vfs_posix_rawfile_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(vfs_posix_rawfile_locals_dict, vfs_posix_rawfile_locals_dict_table);
#if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = { STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = {
.read = vfs_posix_file_read, .read = vfs_posix_file_read,
.write = vfs_posix_file_write, .write = vfs_posix_file_write,
@ -262,7 +258,6 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
.protocol = &vfs_posix_fileio_stream_p, .protocol = &vfs_posix_fileio_stream_p,
.locals_dict = (mp_obj_dict_t *)&vfs_posix_rawfile_locals_dict, .locals_dict = (mp_obj_dict_t *)&vfs_posix_rawfile_locals_dict,
}; };
#endif
STATIC const mp_stream_p_t vfs_posix_textio_stream_p = { STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
.read = vfs_posix_file_read, .read = vfs_posix_file_read,

Wyświetl plik

@ -105,7 +105,6 @@
#define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1)
#define MICROPY_PY_CMATH (0) #define MICROPY_PY_CMATH (0)
#define MICROPY_PY_IO (1) #define MICROPY_PY_IO (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_UERRNO (1) #define MICROPY_PY_UERRNO (1)
#define MICROPY_PY_UERRNO_ERRORCODE (0) #define MICROPY_PY_UERRNO_ERRORCODE (0)
#define MICROPY_PY_THREAD (1) #define MICROPY_PY_THREAD (1)

Wyświetl plik

@ -35,7 +35,6 @@
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
#define MICROPY_PY_MATH_FACTORIAL (0) #define MICROPY_PY_MATH_FACTORIAL (0)
#define MICROPY_PY_MATH_ISCLOSE (0) #define MICROPY_PY_MATH_ISCLOSE (0)
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS)
#define MICROPY_PY_SYS_PS1_PS2 (0) #define MICROPY_PY_SYS_PS1_PS2 (0)
#define MICROPY_PY_UBINASCII_CRC32 (0) #define MICROPY_PY_UBINASCII_CRC32 (0)
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)

Wyświetl plik

@ -101,7 +101,6 @@ uint32_t trng_random_u32(void);
#define MICROPY_PY_MATH_ISCLOSE (1) #define MICROPY_PY_MATH_ISCLOSE (1)
#define MICROPY_PY_CMATH (1) #define MICROPY_PY_CMATH (1)
#define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_IO_IOBASE (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_SYS_PLATFORM "mimxrt" #define MICROPY_PY_SYS_PLATFORM "mimxrt"
#define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1)

Wyświetl plik

@ -155,7 +155,6 @@
#define MICROPY_MODULE_BUILTIN_INIT (1) #define MICROPY_MODULE_BUILTIN_INIT (1)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS_FAT || MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2)
#define MICROPY_PY_URANDOM (1) #define MICROPY_PY_URANDOM (1)
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
#define MICROPY_PY_UTIME_MP_HAL (1) #define MICROPY_PY_UTIME_MP_HAL (1)

Wyświetl plik

@ -83,7 +83,6 @@
#ifndef MICROPY_PY_BUILTINS_HELP_TEXT #ifndef MICROPY_PY_BUILTINS_HELP_TEXT
#define MICROPY_PY_BUILTINS_HELP_TEXT ra_help_text #define MICROPY_PY_BUILTINS_HELP_TEXT ra_help_text
#endif #endif
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS_FAT || MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2)
#ifndef MICROPY_PY_SYS_PLATFORM // let boards override it if they want #ifndef MICROPY_PY_SYS_PLATFORM // let boards override it if they want
#define MICROPY_PY_SYS_PLATFORM "renesas-ra" #define MICROPY_PY_SYS_PLATFORM "renesas-ra"
#endif #endif

Wyświetl plik

@ -77,7 +77,6 @@
#define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1)
#define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_IO (1) #define MICROPY_PY_IO (1)
#define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_IO_IOBASE (1)

Wyświetl plik

@ -11,7 +11,6 @@
#define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_COMPLEX (0)
#define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0)
#define MICROPY_PY_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_FRAMEBUF (0) #define MICROPY_PY_FRAMEBUF (0)
#define MICROPY_PY_USOCKET (0) #define MICROPY_PY_USOCKET (0)
#define MICROPY_PY_NETWORK (0) #define MICROPY_PY_NETWORK (0)

Wyświetl plik

@ -5,7 +5,6 @@
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_OPT_COMPUTED_GOTO (0)
#define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_COMPLEX (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_USOCKET (0) #define MICROPY_PY_USOCKET (0)
#define MICROPY_PY_NETWORK (0) #define MICROPY_PY_NETWORK (0)
#define MICROPY_PY_STM (0) #define MICROPY_PY_STM (0)

Wyświetl plik

@ -11,7 +11,6 @@
#define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_COMPLEX (0)
#define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0)
#define MICROPY_PY_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_FRAMEBUF (0) #define MICROPY_PY_FRAMEBUF (0)
#define MICROPY_PY_USOCKET (0) #define MICROPY_PY_USOCKET (0)
#define MICROPY_PY_NETWORK (0) #define MICROPY_PY_NETWORK (0)

Wyświetl plik

@ -87,7 +87,6 @@
#define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS) #define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS)
#define MICROPY_PY_CMATH (1) #define MICROPY_PY_CMATH (1)
#define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_IO_IOBASE (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1)
#define MICROPY_PY_UERRNO (1) #define MICROPY_PY_UERRNO (1)

Wyświetl plik

@ -86,7 +86,6 @@
#define MICROPY_PY_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_PY_CMATH (0) #define MICROPY_PY_CMATH (0)
#define MICROPY_PY_IO (0) #define MICROPY_PY_IO (0)
#define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_PY_STRUCT (0) #define MICROPY_PY_STRUCT (0)
#define MICROPY_PY_SYS (1) #define MICROPY_PY_SYS (1)
#define MICROPY_PY_SYS_EXIT (0) #define MICROPY_PY_SYS_EXIT (0)

Wyświetl plik

@ -125,7 +125,6 @@
#define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS) #define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS)
#define MICROPY_PY_CMATH (1) #define MICROPY_PY_CMATH (1)
#define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_IO_IOBASE (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_GC_COLLECT_RETVAL (1) #define MICROPY_PY_GC_COLLECT_RETVAL (1)
#ifndef MICROPY_STACKLESS #ifndef MICROPY_STACKLESS
#define MICROPY_STACKLESS (0) #define MICROPY_STACKLESS (0)

Wyświetl plik

@ -1321,11 +1321,6 @@ typedef double mp_float_t;
#define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif #endif
// Whether to provide "io.FileIO" class
#ifndef MICROPY_PY_IO_FILEIO
#define MICROPY_PY_IO_FILEIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif
// Whether to provide "io.BytesIO" class // Whether to provide "io.BytesIO" class
#ifndef MICROPY_PY_IO_BYTESIO #ifndef MICROPY_PY_IO_BYTESIO
#define MICROPY_PY_IO_BYTESIO (1) #define MICROPY_PY_IO_BYTESIO (1)