From 63f47104feec03cd529b80c654a2aa80e3e7d524 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 28 Nov 2017 10:50:53 +1100 Subject: [PATCH] tests/cpydiff: Add difference-test for second arg of builtin next(). --- tests/cpydiff/builtin_next_arg2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/cpydiff/builtin_next_arg2.py diff --git a/tests/cpydiff/builtin_next_arg2.py b/tests/cpydiff/builtin_next_arg2.py new file mode 100644 index 0000000000..cbde773f90 --- /dev/null +++ b/tests/cpydiff/builtin_next_arg2.py @@ -0,0 +1,12 @@ +""" +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))