py/objstringio: Expose tell() on StringIO and BytesIO objects.
To match file objects. Fixes issue #5581.
This commit is contained in:
parent
8a4ce6b79a
commit
ed93778e00
|
@ -228,6 +228,7 @@ STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_tell), MP_ROM_PTR(&mp_stream_tell_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_getvalue), MP_ROM_PTR(&stringio_getvalue_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_getvalue), MP_ROM_PTR(&stringio_getvalue_obj) },
|
||||||
|
|
|
@ -33,6 +33,11 @@ a = io.StringIO()
|
||||||
a.write("foo")
|
a.write("foo")
|
||||||
print(a.read())
|
print(a.read())
|
||||||
|
|
||||||
|
a = io.StringIO()
|
||||||
|
print(a.tell())
|
||||||
|
a.write("foo")
|
||||||
|
print(a.tell())
|
||||||
|
|
||||||
a = io.StringIO()
|
a = io.StringIO()
|
||||||
a.close()
|
a.close()
|
||||||
for f in [a.read, a.getvalue, lambda:a.write("")]:
|
for f in [a.read, a.getvalue, lambda:a.write("")]:
|
||||||
|
|
Loading…
Reference in New Issue