...
 
Commits (9)
......@@ -8,6 +8,7 @@
./run-tests.sh CORE_MICROPYTHON/*.py
./run-tests.sh CORE_STRESS/*.py
./run-tests.sh spacebel_tickets/*.py
./run-tests.sh cpydiff/*.py
./run-tests.sh leon_t1/*.exp
./run-tests.sh -t 2 leon_t2/*.exp
./run-tests.sh -t 10 leon_t10/*.exp
......
Traceback (most recent call last):
File "cpydiff/builtin_next_arg2.py", line 12, in <module>
TypeError: function takes 1 positional arguments but 2 were given
retval = 1
"""
categories: Modules,builtins
description: Second argument to next() is not implemented
cause: MicroPython is optimised for code space.
workaround: Instead of ``val = next(it, deflt)`` use::
try:
val = next(it)
except StopIteration:
val = deflt
"""
print(next(iter(range(0)), 42))
"""
categories: Core,Classes
description: Special method __del__ not implemented for user-defined classes
cause: Unknown
workaround: Unknown
"""
import gc
class Foo():
def __del__(self):
print('__del__')
f = Foo()
del f
gc.collect()
"""
categories: Core,Classes
description: Method Resolution Order (MRO) is not compliant with CPython
cause: Depth first non-exhaustive method resolution order
workaround: Avoid complex class hierarchies with multiple inheritance and complex method overrides. Keep in mind that many languages don't support multiple inheritance at all.
"""
class Foo:
def __str__(self):
return "Foo"
class C(tuple, Foo):
pass
t = C((1, 2, 3))
print(t)
"""
categories: Core,Classes
description: When inheriting from multiple classes super() only calls one class
cause: See :ref:`cpydiff_core_class_mro`
workaround: See :ref:`cpydiff_core_class_mro`
"""
class A:
def __init__(self):
print("A.__init__")
class B(A):
def __init__(self):
print("B.__init__")
super().__init__()
class C(A):
def __init__(self):
print("C.__init__")
super().__init__()
class D(B,C):
def __init__(self):
print("D.__init__")
super().__init__()
D()
"""
categories: Core,Classes
description: Calling super() getter property in subclass will return a property object, not the value
cause: Unknown
workaround: Unknown
"""
class A:
@property
def p(self):
return {"a":10}
class AA(A):
@property
def p(self):
return super().p
a = AA()
print(a.p)
function takes 2 positional arguments but 1 were given
"""
categories: Core,Functions
description: Error messages for methods may display unexpected argument counts
cause: MicroPython counts "self" as an argument.
workaround: Interpret error messages with the information above in mind.
"""
try:
[].append()
except Exception as e:
print(e)
Traceback (most recent call last):
File "cpydiff/core_function_userattr.py", line 10, in <module>
AttributeError: 'function' object has no attribute 'x'
retval = 1
"""
categories: Core,Functions
description: User-defined attributes for functions are not supported
cause: MicroPython is highly optimized for memory usage.
workaround: Use external dictionary, e.g. ``FUNC_X[f] = 0``.
"""
def f():
pass
f.x = 0
print(f.x)
"""
categories: Core,Generator
description: Context manager __exit__() not called in a generator which does not run to completion
cause: Unknown
workaround: Unknown
"""
class foo(object):
def __enter__(self):
print('Enter')
def __exit__(self, *args):
print('Exit')
def bar(x):
with foo():
while True:
x += 1
yield x
def func():
g = bar(0)
for _ in range(3):
print(next(g))
func()
Traceback (most recent call last):
File "cpydiff/core_locals.py", line 11, in <module>
File "cpydiff/core_locals.py", line 9, in test
NotImplementedError: locals() in this context
retval = 1
"""
categories: Core,Runtime
description: Local variables aren't included in locals() result
cause: MicroPython doesn't maintain symbolic local environment, it is optimized to an array of slots. Thus, local variables can't be accessed by a name.
workaround: Unknown
"""
def test():
val = 2
print(locals())
test()
Traceback (most recent call last):
File "cpydiff/modules_array_containment.py", line 8, in <module>
NotImplementedError:
retval = 1
"""
categories: Modules,array
description: Looking for integer not implemented
cause: Unknown
workaround: Unknown
"""
import array
print(1 in array.array('B', b'12'))
Traceback (most recent call last):
File "cpydiff/modules_array_deletion.py", line 9, in <module>
TypeError: 'array' object does not support item deletion
retval = 1
"""
categories: Modules,array
description: Array deletion not implemented
cause: Unknown
workaround: Unknown
"""
import array
a = array.array('b', (1, 2, 3))
del a[1]
print(a)
Traceback (most recent call last):
File "cpydiff/modules_array_subscrstep.py", line 9, in <module>
NotImplementedError: only slices with step=1 (aka None) are supported
retval = 1
"""
categories: Modules,array
description: Subscript with step != 1 is not yet implemented
cause: Unknown
workaround: Unknown
"""
import array
a = array.array('b', (1, 2, 3))
print(a[3:2:2])
Traceback (most recent call last):
File "cpydiff/types_bytearray_sliceassign.py", line 8, in <module>
NotImplementedError: array/bytes required on right side
retval = 1
"""
categories: Types,bytearray
description: Array slice assignment with unsupported RHS
cause: Unknown
workaround: Unknown
"""
b = bytearray(4)
b[0:1] = [1, 2]
print(b)
Traceback (most recent call last):
File "cpydiff/types_bytes_keywords.py", line 7, in <module>
NotImplementedError: keyword argument(s) not yet implemented - use normal args instead
retval = 1
"""
categories: Types,bytes
description: bytes() with keywords not implemented
cause: Unknown
workaround: Pass the encoding as a positional paramter, e.g. ``print(bytes('abc', 'utf-8'))``
"""
print(bytes('abc', encoding='utf8'))
Traceback (most recent call last):
File "cpydiff/types_bytes_subscrstep.py", line 7, in <module>
NotImplementedError: only slices with step=1 (aka None) are supported
retval = 1
"""
categories: Types,bytes
description: Bytes subscription with step != 1 not implemented
cause: MicroPython is highly optimized for memory usage.
workaround: Use explicit loop for this very rare operation.
"""
print(b'123'[0:3:2])
Traceback (most recent call last):
File "cpydiff/types_exception_chaining.py", line 10, in <module>
ValueError:
retval = 1
"""
categories: Types,Exception
description: Exception chaining not implemented
cause: Unknown
workaround: Unknown
"""
try:
raise TypeError
except TypeError:
raise ValueError
Traceback (most recent call last):
File "cpydiff/types_exception_instancevar.py", line 8, in <module>
AttributeError: 'Exception' object has no attribute 'x'
retval = 1
"""
categories: Types,Exception
description: User-defined attributes for builtin exceptions are not supported
cause: MicroPython is highly optimized for memory usage.
workaround: Use user-defined exception subclasses.
"""
e = Exception()
e.x = 0
print(e.x)
iter
iter
Traceback (most recent call last):
File "cpydiff/types_exception_loops.py", line 12, in <module>
IndexError: list index out of range
retval = 1
"""
categories: Types,Exception
description: Exception in while loop condition may have unexpected line number
cause: Condition checks are optimized to happen at the end of loop body, and that line number is reported.
workaround: Unknown
"""
l = ["-foo", "-bar"]
i = 0
while l[i][0] == "-":
print("iter")
i += 1
Traceback (most recent call last):
File "cpydiff/types_exception_subclassinit.py", line 15, in <module>
File "cpydiff/types_exception_subclassinit.py", line 13, in __init__
AttributeError: type object 'Exception' has no attribute '__init__'
retval = 1
"""
categories: Types,Exception
description: Exception.__init__ method does not exist.
cause: Subclassing native classes is not fully supported in MicroPython.
workaround: Call using ``super()`` instead::
class A(Exception):
def __init__(self):
super().__init__()
"""
class A(Exception):
def __init__(self):
Exception.__init__(self)
a = A()
"""
categories: Types,float
description: uPy and CPython outputs formats may differ
cause: Unknown
workaround: Unknown
"""
print('%.1g' % -9.9)
Traceback (most recent call last):
File "cpydiff/types_int_subclassconv.py", line 11, in <module>
File "cpydiff/types_int_subclassconv.py", line 8, in <lambda>
TypeError: can't convert A to int
retval = 1
"""
categories: Types,int
description: No int conversion for int-derived types available
cause: Unknown
workaround: Avoid subclassing builtin types unless really needed. Prefer https://en.wikipedia.org/wiki/Composition_over_inheritance .
"""
class A(int):
__add__ = lambda self, other: A(int(self) + other)
a = A(42)
print(a+a)
Traceback (most recent call last):
File "cpydiff/types_list_delete_subscrstep.py", line 8, in <module>
NotImplementedError:
retval = 1
"""
categories: Types,list
description: List delete with step != 1 not implemented
cause: Unknown
workaround: Use explicit loop for this rare operation.
"""
l = [1, 2, 3, 4]
del l[0:4:2]
print(l)
Traceback (most recent call last):
File "cpydiff/types_list_store_noniter.py", line 8, in <module>
TypeError: object 'range' is not a tuple or list
retval = 1
"""
categories: Types,list
description: List slice-store with non-iterable on RHS is not implemented
cause: RHS is restricted to be a tuple or list
workaround: Use ``list(<iter>)`` on RHS to convert the iterable to a list
"""
l = [10, 20]
l[0:1] = range(4)
print(l)
Traceback (most recent call last):
File "cpydiff/types_list_store_subscrstep.py", line 8, in <module>
NotImplementedError:
retval = 1
"""
categories: Types,list
description: List store with step != 1 not implemented
cause: Unknown
workaround: Use explicit loop for this rare operation.
"""
l = [1, 2, 3, 4]
l[0:4:2] = [5, 6]
print(l)
Traceback (most recent call last):
File "cpydiff/types_str_endswith.py", line 7, in <module>
NotImplementedError: start/end indices
retval = 1
"""
categories: Types,str
description: Start/end indices such as str.endswith(s, start) not implemented
cause: Unknown
workaround: Unknown
"""
print('abc'.endswith('c', 1))
Traceback (most recent call last):
File "cpydiff/types_str_formatsubscr.py", line 7, in <module>
NotImplementedError: attributes not supported yet
retval = 1
"""
categories: Types,str
description: Attributes/subscr not implemented
cause: Unknown
workaround: Unknown
"""
print('{a[0]}'.format(a=[1, 2]))
Traceback (most recent call last):
File "cpydiff/types_str_keywords.py", line 7, in <module>
NotImplementedError: keyword argument(s) not yet implemented - use normal args instead
retval = 1
"""
categories: Types,str
description: str(...) with keywords not implemented
cause: Unknown
workaround: Input the encoding format directly. eg ``print(bytes('abc', 'utf-8'))``
"""
print(str(b'abc', encoding='utf8'))
Traceback (most recent call last):
File "cpydiff/types_str_ljust_rjust.py", line 7, in <module>
AttributeError: 'str' object has no attribute 'ljust'
retval = 1
"""
categories: Types,str
description: str.ljust() and str.rjust() not implemented
cause: MicroPython is highly optimized for memory usage. Easy workarounds available.
workaround: Instead of ``s.ljust(10)`` use ``"%-10s" % s``, instead of ``s.rjust(10)`` use ``"% 10s" % s``. Alternatively, ``"{:<10}".format(s)`` or ``"{:>10}".format(s)``.
"""
print('abc'.ljust(10))
Traceback (most recent call last):
File "cpydiff/types_str_rsplitnone.py", line 7, in <module>
NotImplementedError: rsplit(None,n)
retval = 1
"""
categories: Types,str
description: None as first argument for rsplit such as str.rsplit(None, n) not implemented
cause: Unknown
workaround: Unknown
"""
print('a a a'.rsplit(None, 1))
"""
categories: Types,str
description: Instance of a subclass of str cannot be compared for equality with an instance of a str
cause: Unknown
workaround: Unknown
"""
class S(str):
pass
s = S('hello')
print(s == 'hello')
Traceback (most recent call last):
File "cpydiff/types_str_subscrstep.py", line 7, in <module>
NotImplementedError: only slices with step=1 (aka None) are supported
retval = 1
"""
categories: Types,str
description: Subscript with step != 1 is not yet implemented
cause: Unknown
workaround: Unknown
"""
print('abcdefghi'[0:9:2])
Traceback (most recent call last):
File "cpydiff/types_tuple_subscrstep.py", line 7, in <module>
NotImplementedError: only slices with step=1 (aka None) are supported
retval = 1
"""
categories: Types,tuple
description: Tuple load with step != 1 not implemented
cause: Unknown
workaround: Unknown
"""
print((1, 2, 3, 4)[0:4:2])
3.141592653589793 b'@\t!\xfbTD-\x18'
2.718281828459045 b'@\x05\xbf\n\x8b\x14Wi'
# test that math.pi and math.e constants are exact
import math, array
print(math.pi, bytes(array.array('d', [math.pi])))
print(math.e, bytes(array.array('d', [math.e])))
nan
True
True
True
True
True
1
# test for miscellaneous nan issues reported in Jul/Aug 2018
nan = float('nan')
# negative number to nan
print((-1.0) ** nan)
# nan containment
print(nan in (nan, 1))
print(nan in [nan, 1])
print(nan in {nan, 1})
# object equality enforces reflexivity
print((nan, 1) == (nan, 1))
print([nan, 1] == [nan, 1])
# count behaves like containment
print([nan, 1].count(nan))
......@@ -24,7 +24,7 @@ echo -e "MicroPython port to SPARC/LEON/RTEMS platforms\nCopyright (c) 2015-2018
tar c \
--exclude='build*' --exclude="*.srec" --exclude=".gitignore" --exclude=".gitattributes" \
--exclude="mpy-cross/mpy-cross" --exclude="*.mpy" --exclude="__pycache__" \
--exclude="mpy-cross/mpy-cross" --exclude="mpy-cross/mpy-cross.map" --exclude="*.mpy" --exclude="__pycache__" \
micropython-leon-$REV/{VERSION,makeall,BUILD_GUIDE,CODING_GUIDE,TEST_RESULTS,py,lib/libc,lib/utils,extmod/*.[ch],extmod/crypto-algorithms,extmod/uzlib,tools/mpytool.py,tools/cc1,tools/unhexlify.py,docs/conf.py,mpy-cross,leon-common,leon-ex-minimal,leon-ex-tasks,leon-ex-manager,leon-ex-pystone,leon-for-tests,leon-tests,leon-obcp,leon-spacebel} | gzip > GRL_MPLEON_SWPKG_$REV.tgz
/bin/rm VERSION
......
......@@ -16,6 +16,7 @@ make -C leon-for-tests || exit $?
(cd leon-tests && ./run-tests.sh CORE_MICROPYTHON/*.exp)
(cd leon-tests && ./run-tests.sh CORE_STRESS/*.exp)
(cd leon-tests && ./run-tests.sh spacebel_tickets/*.exp)
(cd leon-tests && ./run-tests.sh cpydiff/*.exp)
(cd leon-tests && ./run-tests.sh leon_t1/*.exp)
(cd leon-tests && ./run-tests.sh -t 2 leon_t2/*.exp)
(cd leon-tests && ./run-tests.sh -t 10 leon_t10/*.exp)
......
......@@ -450,7 +450,7 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser) {
size_t i;
size_t end_block;
size_t start_block;
size_t n_free = 0;
size_t n_free;
int collected = !MP_STATE_MEM(gc_auto_collect_enabled);
#if MICROPY_GC_ALLOC_THRESHOLD
......@@ -464,6 +464,7 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser) {
for (;;) {
// look for a run of n_blocks available blocks
n_free = 0;
for (i = MP_STATE_MEM(gc_last_free_atb_index); i < MP_STATE_MEM(gc_alloc_table_byte_len); i++) {
byte a = MP_STATE_MEM(gc_alloc_table_start)[i];
if (ATB_0_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 0; goto found; } } else { n_free = 0; }
......
......@@ -354,7 +354,7 @@ mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t looku
if (avail_slot == NULL) {
avail_slot = &set->table[pos];
}
} else if (mp_obj_equal(elem, index)) {
} else if (elem == index || mp_obj_equal(elem, index)) {
// found index
if (lookup_kind & MP_MAP_LOOKUP_REMOVE_IF_FOUND) {
// delete element
......
......@@ -179,7 +179,7 @@ static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001))
#if MICROPY_PY_BUILTINS_FLOAT
#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b125769 + 0x8004000000000000))}
#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b145769 + 0x8004000000000000))}
#define mp_const_float_pi {((mp_obj_t)((uint64_t)0x400921fb54442d18 + 0x8004000000000000))}
static inline bool mp_obj_is_float(mp_const_obj_t o) {
......@@ -197,7 +197,12 @@ static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
mp_float_t f;
uint64_t r;
} num = {.f = f};
return num.r + 0x8004000000000000ULL;
mp_obj_t o = num.r + 0x8004000000000000ULL;
if (mp_obj_is_float(o)) {
return o; // object is a valid float object
} else {
return 0x7ff8000000000000ULL + 0x8004000000000000ULL; // return plain nan
}
}
#endif
......
......@@ -296,7 +296,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
if (lhs_val == 0 && rhs_val < 0 && !isinf(rhs_val)) {
goto zero_division_error;
}
if (lhs_val < 0 && rhs_val != MICROPY_FLOAT_C_FUN(floor)(rhs_val)) {
if (lhs_val < 0 && !isnan(rhs_val) && rhs_val != MICROPY_FLOAT_C_FUN(floor)(rhs_val)) {
#if MICROPY_PY_BUILTINS_COMPLEX
return mp_obj_complex_binary_op(MP_BINARY_OP_POWER, lhs_val, 0, rhs_in);
#else
......
......@@ -573,7 +573,7 @@ generic_binary_op:
mp_obj_t iter = mp_getiter(lhs, &iter_buf);
mp_obj_t next;
while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
if (mp_obj_equal(next, rhs)) {
if (next == rhs || mp_obj_equal(next, rhs)) {
return mp_const_true;
}
}
......
......@@ -210,7 +210,7 @@ bool mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp
size_t len = len1 < len2 ? len1 : len2;
for (size_t i = 0; i < len; i++) {
// If current elements equal, can't decide anything - go on
if (mp_obj_equal(items1[i], items2[i])) {
if (items1[i] == items2[i] || mp_obj_equal(items1[i], items2[i])) {
continue;
}
......@@ -266,7 +266,7 @@ mp_obj_t mp_seq_index_obj(const mp_obj_t *items, size_t len, size_t n_args, cons
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) {
size_t count = 0;
for (size_t i = 0; i < len; i++) {
if (mp_obj_equal(items[i], value)) {
if (items[i] == value || mp_obj_equal(items[i], value)) {
count++;
}
}
......