60f5b941e0
mp_reader_new_file() is used to read in files for importing, either .py or .mpy files, for the lexer and persistent code loader respectively. In both cases the file should be opened in raw bytes mode: the lexer handles unicode characters itself, and .mpy files contain 8-bit bytes by nature. Before this commit importing was working correctly because, although the file was opened in text mode, all native filesystem implementations (POSIX, FAT, LFS) would access the file in raw bytes mode via mp_stream_rw() calling mp_stream_p_t.read(). So it was only an issue for non-native filesystems, such as those implemented in Python. For Python-based filesystem implementations, a call to mp_stream_rw() would go via IOBase and then to readinto() at the Python level, and readinto() is only defined on files opened in raw bytes mode. Signed-off-by: Damien George <damien@micropython.org>
13 lines
194 B
Plaintext
13 lines
194 B
Plaintext
open /data.txt r
|
|
some data in a text file
|
|
stat /usermod1
|
|
stat /usermod1.py
|
|
open /usermod1.py rb
|
|
ioctl 4 0
|
|
in usermod1
|
|
stat /usermod2
|
|
stat /usermod2.py
|
|
open /usermod2.py rb
|
|
ioctl 4 0
|
|
in usermod2
|