Skip to content

Commit 8f4c108

Browse files
committed
all: Remove MICROPY_PY_IO_FILEIO config option.
Since commit e65d1e6 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>
1 parent 237a393 commit 8f4c108

17 files changed

Lines changed: 0 additions & 31 deletions

File tree

examples/embedding/mpconfigport_minimal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#define MICROPY_PY_MATH (0)
7070
#define MICROPY_PY_CMATH (0)
7171
#define MICROPY_PY_IO (0)
72-
#define MICROPY_PY_IO_FILEIO (0)
7372
#define MICROPY_PY_STRUCT (0)
7473
#define MICROPY_PY_SYS (1)
7574
#define MICROPY_PY_SYS_EXIT (0)

extmod/vfs_fat_file.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ STATIC const mp_rom_map_elem_t vfs_fat_rawfile_locals_dict_table[] = {
170170

171171
STATIC MP_DEFINE_CONST_DICT(vfs_fat_rawfile_locals_dict, vfs_fat_rawfile_locals_dict_table);
172172

173-
#if MICROPY_PY_IO_FILEIO
174173
STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = {
175174
.read = file_obj_read,
176175
.write = file_obj_write,
@@ -186,7 +185,6 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
186185
.protocol = &vfs_fat_fileio_stream_p,
187186
.locals_dict = (mp_obj_dict_t *)&vfs_fat_rawfile_locals_dict,
188187
};
189-
#endif
190188

191189
STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
192190
.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
230228
case '+':
231229
mode |= FA_READ | FA_WRITE;
232230
break;
233-
#if MICROPY_PY_IO_FILEIO
234231
case 'b':
235232
type = &mp_type_vfs_fat_fileio;
236233
break;
237-
#endif
238234
case 't':
239235
type = &mp_type_vfs_fat_textio;
240236
break;

extmod/vfs_lfsx_file.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6868
case '+':
6969
flags |= LFSx_MACRO(_O_RDWR);
7070
break;
71-
#if MICROPY_PY_IO_FILEIO
7271
case 'b':
7372
type = &MP_TYPE_VFS_LFSx_(_fileio);
7473
break;
75-
#endif
7674
case 't':
7775
type = &MP_TYPE_VFS_LFSx_(_textio);
7876
break;
@@ -216,7 +214,6 @@ STATIC const mp_rom_map_elem_t MP_VFS_LFSx(file_locals_dict_table)[] = {
216214
};
217215
STATIC MP_DEFINE_CONST_DICT(MP_VFS_LFSx(file_locals_dict), MP_VFS_LFSx(file_locals_dict_table));
218216

219-
#if MICROPY_PY_IO_FILEIO
220217
STATIC const mp_stream_p_t MP_VFS_LFSx(fileio_stream_p) = {
221218
.read = MP_VFS_LFSx(file_read),
222219
.write = MP_VFS_LFSx(file_write),
@@ -232,7 +229,6 @@ const mp_obj_type_t MP_TYPE_VFS_LFSx_(_fileio) = {
232229
.protocol = &MP_VFS_LFSx(fileio_stream_p),
233230
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
234231
};
235-
#endif
236232

237233
STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
238234
.read = MP_VFS_LFSx(file_read),

extmod/vfs_posix_file.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,12 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
8383
case '+':
8484
mode_rw = O_RDWR;
8585
break;
86-
#if MICROPY_PY_IO_FILEIO
87-
// If we don't have io.FileIO, then files are in text mode implicitly
8886
case 'b':
8987
type = &mp_type_vfs_posix_fileio;
9088
break;
9189
case 't':
9290
type = &mp_type_vfs_posix_textio;
9391
break;
94-
#endif
9592
}
9693
}
9794

@@ -246,7 +243,6 @@ STATIC const mp_rom_map_elem_t vfs_posix_rawfile_locals_dict_table[] = {
246243

247244
STATIC MP_DEFINE_CONST_DICT(vfs_posix_rawfile_locals_dict, vfs_posix_rawfile_locals_dict_table);
248245

249-
#if MICROPY_PY_IO_FILEIO
250246
STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = {
251247
.read = vfs_posix_file_read,
252248
.write = vfs_posix_file_write,
@@ -262,7 +258,6 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
262258
.protocol = &vfs_posix_fileio_stream_p,
263259
.locals_dict = (mp_obj_dict_t *)&vfs_posix_rawfile_locals_dict,
264260
};
265-
#endif
266261

267262
STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
268263
.read = vfs_posix_file_read,

ports/cc3200/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
#define MICROPY_PY_SYS_STDFILES (1)
106106
#define MICROPY_PY_CMATH (0)
107107
#define MICROPY_PY_IO (1)
108-
#define MICROPY_PY_IO_FILEIO (1)
109108
#define MICROPY_PY_UERRNO (1)
110109
#define MICROPY_PY_UERRNO_ERRORCODE (0)
111110
#define MICROPY_PY_THREAD (1)

ports/esp8266/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
3636
#define MICROPY_PY_MATH_FACTORIAL (0)
3737
#define MICROPY_PY_MATH_ISCLOSE (0)
38-
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS)
3938
#define MICROPY_PY_SYS_PS1_PS2 (0)
4039
#define MICROPY_PY_UBINASCII_CRC32 (0)
4140
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)

ports/mimxrt/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ uint32_t trng_random_u32(void);
101101
#define MICROPY_PY_MATH_ISCLOSE (1)
102102
#define MICROPY_PY_CMATH (1)
103103
#define MICROPY_PY_IO_IOBASE (1)
104-
#define MICROPY_PY_IO_FILEIO (1)
105104
#define MICROPY_PY_SYS_MAXSIZE (1)
106105
#define MICROPY_PY_SYS_PLATFORM "mimxrt"
107106
#define MICROPY_PY_SYS_STDFILES (1)

ports/nrf/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@
155155
#define MICROPY_MODULE_BUILTIN_INIT (1)
156156
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
157157
#define MICROPY_PY_SYS_MAXSIZE (1)
158-
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS_FAT || MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2)
159158
#define MICROPY_PY_URANDOM (1)
160159
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
161160
#define MICROPY_PY_UTIME_MP_HAL (1)

ports/renesas-ra/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
8484
#define MICROPY_PY_BUILTINS_HELP_TEXT ra_help_text
8585
#endif
86-
#define MICROPY_PY_IO_FILEIO (MICROPY_VFS_FAT || MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2)
8786
#ifndef MICROPY_PY_SYS_PLATFORM // let boards override it if they want
8887
#define MICROPY_PY_SYS_PLATFORM "renesas-ra"
8988
#endif

ports/samd/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
#define MICROPY_PY_SYS_EXIT (1)
7878
#define MICROPY_PY_SYS_STDFILES (1)
7979
#define MICROPY_PY_SYS_MAXSIZE (1)
80-
#define MICROPY_PY_IO_FILEIO (1)
8180
#define MICROPY_PY_IO (1)
8281
#define MICROPY_PY_IO_IOBASE (1)
8382

0 commit comments

Comments
 (0)