SHA2017-badge / micropython-esp32

MicroPython ported to the SHA2017 badge
https://micropython.org/
MIT License
12 stars 16 forks source link

open() does not allow binary IO #146

Closed polyfloyd closed 7 years ago

polyfloyd commented 7 years ago

Reading files opened by open("rb") returns a TextIOWrapper instead of something that allows binary IO. The emulator returns an instance of FileIO which seems to work just fine.

with open("somefile", "rb") as f:
    print(type(f)) # TextIOWrapper, expected be FileIO (or BufferedReader according to the Python documentation)

As a consequence, f.read() returns a str instead of bytes.

basvs commented 7 years ago

hmm.. it should return FileIO.. diving into it..

basvs commented 7 years ago

probably fixed in pull-request #166

annejan commented 7 years ago

@polyfloyd can you verify if current master solves this issue for you?

polyfloyd commented 7 years ago

@annejan Yeah, it has.