Merge branch 'master' of github.com:micropython/micropython
This commit is contained in:
commit
561f83c9cf
|
@ -30,7 +30,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "%.8g", (double) o->value);
|
sprintf(buf, "%.17g", (double) o->value);
|
||||||
print(env, buf);
|
print(env, buf);
|
||||||
if (strchr(buf, '.') == NULL) {
|
if (strchr(buf, '.') == NULL) {
|
||||||
// Python floats always have decimal point
|
// Python floats always have decimal point
|
||||||
|
|
|
@ -1060,10 +1060,14 @@ import_error:
|
||||||
void mp_import_all(mp_obj_t module) {
|
void mp_import_all(mp_obj_t module) {
|
||||||
DEBUG_printf("import all %p\n", module);
|
DEBUG_printf("import all %p\n", module);
|
||||||
|
|
||||||
|
// TODO: Support __all__
|
||||||
mp_map_t *map = mp_obj_dict_get_map(mp_obj_module_get_globals(module));
|
mp_map_t *map = mp_obj_dict_get_map(mp_obj_module_get_globals(module));
|
||||||
for (uint i = 0; i < map->alloc; i++) {
|
for (uint i = 0; i < map->alloc; i++) {
|
||||||
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
|
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
|
||||||
mp_store_name(MP_OBJ_QSTR_VALUE(map->table[i].key), map->table[i].value);
|
qstr name = MP_OBJ_QSTR_VALUE(map->table[i].key);
|
||||||
|
if (*qstr_str(name) != '_') {
|
||||||
|
mp_store_name(name, map->table[i].value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -108,21 +109,23 @@ bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = len1 < len2 ? len1 : len2;
|
int len = len1 < len2 ? len1 : len2;
|
||||||
bool eq_status = true; // empty lists are equal
|
|
||||||
bool rel_status;
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
eq_status = mp_obj_equal(items1[i], items2[i]);
|
// If current elements equal, can't decide anything - go on
|
||||||
if (op == MP_BINARY_OP_EQUAL && !eq_status) {
|
if (mp_obj_equal(items1[i], items2[i])) {
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
rel_status = (mp_binary_op(op, items1[i], items2[i]) == mp_const_true);
|
|
||||||
if (!eq_status && !rel_status) {
|
// Othewise, if they are not equal, we can have final decision based on them
|
||||||
|
if (op == MP_BINARY_OP_EQUAL) {
|
||||||
|
// In particular, if we are checking for equality, here're the answer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, application of relation op gives the answer
|
||||||
|
return (mp_binary_op(op, items1[i], items2[i]) == mp_const_true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we had tie in the last element...
|
// If we had tie in the last element...
|
||||||
if (eq_status) {
|
|
||||||
// ... and we have lists of different lengths...
|
// ... and we have lists of different lengths...
|
||||||
if (len1 != len2) {
|
if (len1 != len2) {
|
||||||
if (len1 < len2) {
|
if (len1 < len2) {
|
||||||
|
@ -130,10 +133,9 @@ bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (op == MP_BINARY_OP_MORE) {
|
} else if (op == MP_BINARY_OP_MORE) {
|
||||||
// Otherwise, if we have strict relation, equality means failure
|
// Otherwise, if we have strict relation, sequence equality means failure
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,3 +48,8 @@ print((1,) <= (1, 0,))
|
||||||
print((1,) <= (1, -1,))
|
print((1,) <= (1, -1,))
|
||||||
print((1, 0,) <= (1,))
|
print((1, 0,) <= (1,))
|
||||||
print((1, -1,) <= (1,))
|
print((1, -1,) <= (1,))
|
||||||
|
|
||||||
|
print((10, 0) > (1, 1))
|
||||||
|
print((10, 0) < (1, 1))
|
||||||
|
print((0, 0, 10, 0) > (0, 0, 1, 1))
|
||||||
|
print((0, 0, 10, 0) < (0, 0, 1, 1))
|
||||||
|
|
Loading…
Reference in New Issue