py: mp_buffer_info_t::buf may be valid, but NULL for empty objects.

This happens for example for zero-size arrays. As .get_buffer() method now
has explicit return value, it's enough to distinguish success vs failure
of getting buffer.
This commit is contained in:
Paul Sokolovsky 2014-08-10 11:46:10 +03:00
parent 5f47ebbf82
commit 7133d91773
2 changed files with 2 additions and 2 deletions

View File

@ -410,7 +410,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
return false;
}
int ret = type->buffer_p.get_buffer(obj, bufinfo, flags);
if (ret != 0 || bufinfo->buf == NULL) {
if (ret != 0) {
return false;
}
return true;

View File

@ -210,7 +210,7 @@ typedef struct _mp_buffer_info_t {
// them with ver = sizeof(struct). Cons: overkill for *micro*?
//int ver; // ?
void *buf;
void *buf; // can be NULL if len == 0
mp_int_t len; // in bytes
int typecode; // as per binary.h