Deal with reading a buffer less than what was allocated.

With this fix, file_long_read now passes.
> So, are you happy with mp_uint_t as a return type, with MP_STREAM_ERROR =
-1?

Yes, I think that should be done asap, and later we can consider other
possibilities for API refactoring.



On Fri, Jul 25, 2014 at 11:03 PM, Damien George <notifications@github.com>
wrote:

> In py/stream.c:
>
> > @@ -97,7 +97,7 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
> >              }
> >              int error;
> >              mp_int_t out_sz = o->type->stream_p->read(o, p, more_bytes, &error);
> > -            if (out_sz == -1) {
> > +            if (out_sz < 0) {
>
> Ok, fair point about memory access for errcode. To go down the path I
> suggested, really the type declaration should be inverted to return the
> "status", and the size should be passed by a pointer as the last arg.
>
> So, are you happy with mp_uint_t as a return type, with MP_STREAM_ERROR =
> -1?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/micropython/micropython/pull/767/files#r15421475>.
>