py: Use mp_uint_t where appropriate in stream functions.
This commit is contained in:
parent
e294bee45b
commit
d00d8ac95c
14
py/stream.c
14
py/stream.c
@ -60,7 +60,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in);
|
||||
|
||||
#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes)
|
||||
|
||||
STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stream_read(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0];
|
||||
if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@ -215,7 +215,7 @@ STATIC mp_obj_t stream_write_method(mp_obj_t self_in, mp_obj_t arg) {
|
||||
return mp_stream_write(self_in, bufinfo.buf, bufinfo.len);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t stream_readinto(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stream_readinto(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0];
|
||||
if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@ -254,12 +254,12 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation not supported"));
|
||||
}
|
||||
|
||||
int total_size = 0;
|
||||
mp_uint_t total_size = 0;
|
||||
vstr_t *vstr = vstr_new_size(DEFAULT_BUFFER_SIZE);
|
||||
char *p = vstr_str(vstr);
|
||||
int error;
|
||||
int current_read = DEFAULT_BUFFER_SIZE;
|
||||
mp_uint_t current_read = DEFAULT_BUFFER_SIZE;
|
||||
while (true) {
|
||||
int error;
|
||||
mp_uint_t out_sz = o->type->stream_p->read(self_in, p, current_read, &error);
|
||||
if (out_sz == MP_STREAM_ERROR) {
|
||||
if (is_nonblocking_error(error)) {
|
||||
@ -296,7 +296,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
|
||||
}
|
||||
|
||||
// Unbuffered, inefficient implementation of readline() for raw I/O files.
|
||||
STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t stream_unbuffered_readline(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0];
|
||||
if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) {
|
||||
// CPython: io.UnsupportedOperation, OSError subclass
|
||||
@ -315,13 +315,13 @@ STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
|
||||
vstr = vstr_new();
|
||||
}
|
||||
|
||||
int error;
|
||||
while (max_size == -1 || max_size-- != 0) {
|
||||
char *p = vstr_add_len(vstr, 1);
|
||||
if (p == NULL) {
|
||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "out of memory"));
|
||||
}
|
||||
|
||||
int error;
|
||||
mp_uint_t out_sz = o->type->stream_p->read(o, p, 1, &error);
|
||||
if (out_sz == MP_STREAM_ERROR) {
|
||||
if (is_nonblocking_error(error)) {
|
||||
|
Loading…
Reference in New Issue
Block a user