Skip to content

Commit cdc020d

Browse files
committed
objstrunicode: Re-add buffer protocol back for now, required for io.StringIO.
1 parent e7f2b4c commit cdc020d

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ STATIC mp_obj_t str_encode(uint n_args, const mp_obj_t *args) {
16011601
}
16021602
#endif
16031603

1604-
STATIC machine_int_t str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, int flags) {
1604+
machine_int_t str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, int flags) {
16051605
if (flags == MP_BUFFER_READ) {
16061606
GET_STR_DATA_LEN(self_in, str_data, str_len);
16071607
bufinfo->buf = (void*)str_data;

py/objstr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args);
5555
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, uint len);
5656

5757
mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in);
58+
machine_int_t str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, int flags);
5859

5960
MP_DECLARE_CONST_FUN_OBJ(str_encode_obj);
6061
MP_DECLARE_CONST_FUN_OBJ(str_find_obj);

py/objstrunicode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ const mp_obj_type_t mp_type_str = {
313313
.binary_op = str_binary_op,
314314
.subscr = str_subscr,
315315
.getiter = mp_obj_new_str_iterator,
316-
// .buffer_p = { .get_buffer = str_get_buffer },
316+
.buffer_p = { .get_buffer = str_get_buffer },
317317
.locals_dict = (mp_obj_t)&str_locals_dict,
318318
};
319319

0 commit comments

Comments
 (0)