top: Update Python formatting to black "2023 stable style".

See https://black.readthedocs.io/en/stable/the_black_code_style/index.html

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-02-02 11:51:48 +11:00
parent fe2a8332ff
commit 8b27482692
75 changed files with 208 additions and 123 deletions

View File

@ -10,7 +10,6 @@ switch = pyb.Switch()
# loop
while True:
# wait for interrupt
# this reduces power consumption while waiting for switch press
pyb.wfi()

View File

@ -1,6 +1,5 @@
@micropython.asm_thumb
def asm_sum_words(r0, r1):
# r0 = len
# r1 = ptr
# r2 = sum
@ -25,7 +24,6 @@ def asm_sum_words(r0, r1):
@micropython.asm_thumb
def asm_sum_bytes(r0, r1):
# r0 = len
# r1 = ptr
# r2 = sum

View File

@ -20,6 +20,7 @@ if hasattr(machine, "Timer"):
else:
_timer = None
# Batch writes into 50ms intervals.
def schedule_in(handler, delay_ms):
def _wrap(_arg):

View File

@ -4,6 +4,7 @@ import pyb
lcd = pyb.LCD("x")
lcd.light(1)
# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates

View File

@ -8,6 +8,7 @@ import time
from machine import Pin
import rp2
# Define an empty program that uses a single set pin.
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def prog():

View File

@ -33,6 +33,7 @@ for i in range(NUM_UARTS):
sm.active(1)
uarts.append(sm)
# We can print characters from each UART by pushing them to the TX FIFO
def pio_uart_print(sm, s):
for c in s:

View File

@ -18,6 +18,7 @@ _attrs = {
"StreamWriter": "stream",
}
# Lazy loader, effectively does:
# global attr
# from .mod import attr

View File

@ -30,6 +30,7 @@ _exc_context = {"message": "Task exception wasn't retrieved", "exception": None,
################################################################################
# Sleep functions
# "Yield" once, then raise StopIteration
class SingletonGenerator:
def __init__(self):
@ -132,6 +133,7 @@ class IOQueue:
################################################################################
# Main run loop
# Ensure the awaitable is a task
def _promote_to_task(aw):
return aw if isinstance(aw, Task) else create_task(aw)

View File

@ -3,6 +3,7 @@
from . import core
# Event class for primitive events that can be waited on, set, and cleared
class Event:
def __init__(self):

View File

@ -3,6 +3,7 @@
from . import core
# Lock class for primitive mutex capability
class Lock:
def __init__(self):

View File

@ -39,6 +39,7 @@ AMB_LIGHT = const(4)
# Helper functions
# LED & Ambient Light Sensor control
def set_led(state):
l = Pin(LED, Pin.OUT)

View File

@ -38,6 +38,7 @@ I2C_SCL = const(9)
DAC1 = const(17)
DAC2 = const(18)
# Helper functions
def set_pixel_power(state):
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""

View File

@ -32,6 +32,7 @@ I2C_SCL = const(9)
# Helper functions
# LED & Ambient Light Sensor control
def led_set(state):
"""Set the state of the BLUE LED on IO13"""

View File

@ -28,6 +28,7 @@ SPI_CLK = const(36)
I2C_SDA = const(8)
I2C_SCL = const(9)
# Helper functions
def set_ldo2_power(state):
"""Enable or Disable power to the second LDO"""

View File

@ -39,6 +39,7 @@ DAC2 = const(26)
# Helper functions
# Get a *rough* estimate of the current battery voltage
# If the battery is not present, the charge IC will still report it's trying to charge at X voltage
# so it will still show a voltage.

View File

@ -28,6 +28,7 @@ SPI_CLK = const(36)
I2C_SDA = const(8)
I2C_SCL = const(9)
# Helper functions
def set_pixel_power(state):
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""

View File

@ -14,7 +14,6 @@ assert len(sys.argv) == 4
md5 = hashlib.md5()
with open(sys.argv[3], "wb") as fout:
with open(sys.argv[1], "rb") as f:
data_flash = f.read()
fout.write(data_flash)

View File

@ -5,7 +5,6 @@ import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
fid = esp.flash_id()

View File

@ -53,6 +53,7 @@ According to AN12077:
"""
ocram_min_size = 0x00010000 # 64 KB
# Value parser
def mimxrt_default_parser(defines_file, features_file, ld_script):
with open(ld_script, "r") as input_file:

View File

@ -187,7 +187,6 @@ class PowerUp3:
self.old_speed = 0
while True:
time.sleep_ms(100)
# read out new angle

View File

@ -65,7 +65,6 @@ def get_details(release_notes, filename):
def main(src_path, dest_path):
# Load the release note to parse for important details
with open(os.path.join(src_path, _RELEASE_NOTES), "rb") as f:
release_notes = f.read()

View File

@ -506,7 +506,6 @@ class Pins(object):
def print_af_defs(self, af_defs_filename, cmp_strings):
with open(af_defs_filename, "wt") as af_defs_file:
STATIC_AF_TOKENS = {}
for named_pin in self.cpu_pins:
for af in named_pin.pin().alt_fn:

View File

@ -29,6 +29,7 @@ elif platform.python_version_tuple()[0] == "3":
# end compatibility code
# given a list of (name,regex) pairs, find the first one that matches the given line
def re_match_first(regexs, line):
for name, regex in regexs:

View File

@ -222,6 +222,7 @@ static_qstr_list = [
"zip",
]
# this must match the equivalent function in qstr.c
def compute_hash(qstr, bytes_hash):
hash = 5381

View File

@ -5,6 +5,7 @@ except ImportError:
print("SKIP")
raise SystemExit
# region tuple is: (size, free, largest free, min free)
# we check that each region's size is > 0 and that the free amounts are smaller than the size
def chk_heap(kind, regions):

View File

@ -34,6 +34,7 @@ fb.pixel(2, 2, 0x0708)
fb2.blit(fb, 0, 0)
print(bytes(fb2))
# Test that blitting something that isn't a subclass fails with TypeError.
class NotAFrameBuf:
pass

View File

@ -9,6 +9,7 @@ except ImportError:
print("SKIP")
raise SystemExit
# main task raising an exception
async def main():
print("main start")
@ -21,6 +22,7 @@ try:
except ValueError as er:
print("ValueError", er.args[0])
# sub-task raising an exception
async def task():
print("task start")
@ -40,6 +42,7 @@ try:
except ValueError as er:
print("ValueError", er.args[0])
# main task raising an exception with sub-task not yet scheduled
# TODO not currently working, task is never scheduled
async def task():

View File

@ -13,7 +13,6 @@ except AttributeError:
class RAMFS:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -13,7 +13,6 @@ except AttributeError:
class RAMFS:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -12,7 +12,6 @@ except AttributeError:
class RAMFS:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -13,7 +13,6 @@ except AttributeError:
class RAMFS_OLD:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -13,7 +13,6 @@ except AttributeError:
class RAMFS:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -14,7 +14,6 @@ except AttributeError:
class RAMBDevSparse:
SEC_SIZE = 512
def __init__(self, blocks):

View File

@ -6,6 +6,7 @@ except ImportError:
print("SKIP")
raise SystemExit
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))

View File

@ -8,6 +8,7 @@ try:
except AttributeError:
pass
# define __getattr__
def __getattr__(attr):
if attr == "does_not_exist":

View File

@ -1,6 +1,5 @@
@micropython.asm_thumb
def asm_sum_words(r0, r1):
# r0 = len
# r1 = ptr
# r2 = sum
@ -25,7 +24,6 @@ def asm_sum_words(r0, r1):
@micropython.asm_thumb
def asm_sum_bytes(r0, r1):
# r0 = len
# r1 = ptr
# r2 = sum

View File

@ -11,6 +11,7 @@ import micropython as X
print(globals()["X"])
# function name that matches a constant
def X():
print("function X", X)
@ -18,6 +19,7 @@ def X():
globals()["X"]()
# arguments that match a constant
def f(X, *Y, **Z):
pass
@ -25,6 +27,7 @@ def f(X, *Y, **Z):
f(1)
# class name that matches a constant
class X:
def f(self):
@ -33,6 +36,7 @@ class X:
globals()["X"]().f()
# constant within a class
class A:
C1 = const(4)

View File

@ -2,6 +2,7 @@
import micropython
# Yielding from a function generator
def sub_gen(a):
for i in range(a):
@ -18,6 +19,7 @@ print(next(g))
print(next(g))
micropython.heap_unlock()
# Yielding from a user iterator
class G:
def __init__(self):

View File

@ -1,5 +1,6 @@
# test native emitter can handle closures correctly
# basic closure
@micropython.native
def f():
@ -15,6 +16,7 @@ def f():
print(f()())
# closing over an argument
@micropython.native
def f(x):
@ -28,6 +30,7 @@ def f(x):
print(f(2)())
# closing over an argument and a normal local
@micropython.native
def f(x):

View File

@ -1,5 +1,6 @@
# test for native generators
# simple generator with yield and return
@micropython.native
def gen1(x):
@ -16,6 +17,7 @@ try:
except StopIteration as e:
print(e.args[0])
# using yield from
@micropython.native
def gen2(x):

View File

@ -1,5 +1,6 @@
# tests for natively compiled functions
# basic test
@micropython.native
def native_test(x):
@ -14,6 +15,7 @@ import gc
gc.collect()
native_test(3)
# native with 2 args
@micropython.native
def f(a, b):
@ -22,6 +24,7 @@ def f(a, b):
f(1, 2)
# native with 3 args
@micropython.native
def f(a, b, c):
@ -30,6 +33,7 @@ def f(a, b, c):
f(1, 2, 3)
# check not operator
@micropython.native
def f(a):

View File

@ -1,5 +1,6 @@
# test native try handling
# basic try-finally
@micropython.native
def f():
@ -14,6 +15,7 @@ try:
except NameError:
print("NameError")
# nested try-except with try-finally
@micropython.native
def f():
@ -28,6 +30,7 @@ def f():
f()
# check that locals written to in try blocks keep their values
@micropython.native
def f():

View File

@ -1,5 +1,6 @@
# test native try handling
# deeply nested try (9 deep)
@micropython.native
def f():

View File

@ -21,6 +21,7 @@ def f():
f()
# nested with and try-except
@micropython.native
def f():

View File

@ -56,6 +56,7 @@ def f6(x1: int, x2: int, x3: int, x4: int, x5: int, x6: int):
f6(1, 2, 3, 4, 5, 6)
# test compiling *x, **x, * args (currently unsupported at runtime)
@micropython.viper
def f(*x, **y):

View File

@ -10,6 +10,7 @@ def f():
f()
# using True as a conditional
@micropython.viper
def f():
@ -20,6 +21,7 @@ def f():
f()
# using an int as a conditional
@micropython.viper
def g():
@ -30,6 +32,7 @@ def g():
g()
# using an int as a conditional that has the lower 16-bits clear
@micropython.viper
def h():

View File

@ -1,5 +1,6 @@
import micropython
# viper function taking and returning ints
@micropython.viper
def viper_int(x: int, y: int) -> int:
@ -8,6 +9,7 @@ def viper_int(x: int, y: int) -> int:
print(viper_int(1, 2))
# viper function taking and returning objects
@micropython.viper
def viper_object(x: object, y: object) -> object:
@ -16,6 +18,7 @@ def viper_object(x: object, y: object) -> object:
print(viper_object(1, 2))
# return None as non-object (should return 0)
@micropython.viper
def viper_ret_none() -> int:
@ -24,6 +27,7 @@ def viper_ret_none() -> int:
print(viper_ret_none())
# return Ellipsis as object
@micropython.viper
def viper_ret_ellipsis() -> object:
@ -32,6 +36,7 @@ def viper_ret_ellipsis() -> object:
print(viper_ret_ellipsis())
# 3 args
@micropython.viper
def viper_3args(a: int, b: int, c: int) -> int:
@ -40,6 +45,7 @@ def viper_3args(a: int, b: int, c: int) -> int:
print(viper_3args(1, 2, 3))
# 4 args
@micropython.viper
def viper_4args(a: int, b: int, c: int, d: int) -> int:
@ -49,6 +55,7 @@ def viper_4args(a: int, b: int, c: int, d: int) -> int:
# viper call with 4 args not yet supported
# print(viper_4args(1, 2, 3, 4))
# a local (should have automatic type int)
@micropython.viper
def viper_local(x: int) -> int:
@ -58,6 +65,7 @@ def viper_local(x: int) -> int:
print(viper_local(3))
# without type annotation, types should default to object
@micropython.viper
def viper_no_annotation(x, y):
@ -66,6 +74,7 @@ def viper_no_annotation(x, y):
print(viper_no_annotation(4, 5))
# a for loop
@micropython.viper
def viper_for(a: int, b: int) -> int:
@ -77,6 +86,7 @@ def viper_for(a: int, b: int) -> int:
print(viper_for(10, 10000))
# accessing a global
@micropython.viper
def viper_access_global():
@ -87,6 +97,7 @@ def viper_access_global():
print(viper_access_global(), gl)
# calling print with object and int types
@micropython.viper
def viper_print(x, y: int):
@ -95,6 +106,7 @@ def viper_print(x, y: int):
viper_print(1, 2)
# convert constants to objects in tuple
@micropython.viper
def viper_tuple_consts(x):
@ -103,6 +115,7 @@ def viper_tuple_consts(x):
print(viper_tuple_consts(0))
# making a tuple from an object and an int
@micropython.viper
def viper_tuple(x, y: int):
@ -111,6 +124,7 @@ def viper_tuple(x, y: int):
print(viper_tuple(1, 2))
# making a list from an object and an int
@micropython.viper
def viper_list(x, y: int):
@ -119,6 +133,7 @@ def viper_list(x, y: int):
print(viper_list(1, 2))
# making a set from an object and an int
@micropython.viper
def viper_set(x, y: int):
@ -127,6 +142,7 @@ def viper_set(x, y: int):
print(sorted(list(viper_set(1, 2))))
# raising an exception
@micropython.viper
def viper_raise(x: int):
@ -138,6 +154,7 @@ try:
except OSError as e:
print(repr(e))
# calling GC after defining the function
@micropython.viper
def viper_gc() -> int:

View File

@ -1,5 +1,6 @@
# Miscellaneous viper tests
# Test correct use of registers in load and store
@micropython.viper
def expand(dest: ptr8, source: ptr8, length: int):

View File

@ -1,5 +1,6 @@
import micropython
# unsigned ints
@micropython.viper
def viper_uint() -> uint:

View File

@ -1,5 +1,6 @@
# test try handling within a viper function
# basic try-finally
@micropython.viper
def f():
@ -14,6 +15,7 @@ try:
except NameError:
print("NameError")
# nested try-except with try-finally
@micropython.viper
def f():
@ -28,6 +30,7 @@ def f():
f()
# check that locals written to in try blocks keep their values
@micropython.viper
def f():

View File

@ -2,6 +2,7 @@
import micropython
# converting incoming arg to bool
@micropython.viper
def f1(x: bool):
@ -13,6 +14,7 @@ f1(1)
f1([])
f1([1])
# taking and returning a bool
@micropython.viper
def f2(x: bool) -> bool:
@ -22,6 +24,7 @@ def f2(x: bool) -> bool:
print(f2([]))
print(f2([1]))
# converting to bool within function
@micropython.viper
def f3(x) -> bool:

View File

@ -21,6 +21,7 @@ def f():
f()
# nested with and try-except
@micropython.viper
def f():

View File

@ -117,6 +117,7 @@ try:
except NotImplementedError:
print("NotImplementedError")
# can't assign attributes to a function
def f():
pass
@ -133,6 +134,7 @@ try:
except TypeError:
print("TypeError")
# test when object explicitly listed at not-last position in parent tuple
# this is not compliant with CPython because of illegal MRO
class A:
@ -146,6 +148,7 @@ class B(object, A):
B().foo()
# can't assign property (or other special accessors) to already-subclassed class
class A:
pass

View File

@ -40,6 +40,7 @@ except Exception as e:
print("caught")
print_exc(e)
# exception message with more than 1 source-code line
def f():
g()
@ -77,6 +78,7 @@ except Exception as e:
print("caught")
print_exc(e)
# Here we have a function with lots of bytecode generated for a single source-line, and
# there is an error right at the end of the bytecode. It should report the correct line.
def f():

View File

@ -48,11 +48,9 @@ def test_generator():
gen = make_gen()
r = 0
try:
r += gen.send(None)
while True:
r += gen.send(None)
except StopIteration as e:

View File

@ -1,195 +1,195 @@
### trace_handler::main event: call
0: @__main__:test_generator => sys_settrace_generator.py:41
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:42
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:48
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:49
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:50
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:52
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:51
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:42
1: @__main__:test_generator => sys_settrace_generator.py:52
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:51
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:52
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:51
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:52
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:51
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:56
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:54
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:46
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:46
1: @__main__:test_generator => sys_settrace_generator.py:56
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:54
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: exception
0: @__main__:test_generator => sys_settrace_generator.py:54
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:56
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:58
1: @__main__:<module> => sys_settrace_generator.py:69
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:59
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:57
1: @__main__:<module> => sys_settrace_generator.py:67
test_generator 7 8
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:59
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:60
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:69
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:62
1: @__main__:<module> => sys_settrace_generator.py:69
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:42
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:64
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:62
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:43
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:64
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:62
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:44
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:64
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:62
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:61
1: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: call
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:45
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:make_gen => sys_settrace_generator.py:46
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: return
0: @__main__:make_gen => sys_settrace_generator.py:46
1: @__main__:test_generator => sys_settrace_generator.py:63
2: @__main__:<module> => sys_settrace_generator.py:69
1: @__main__:test_generator => sys_settrace_generator.py:61
2: @__main__:<module> => sys_settrace_generator.py:67
### trace_handler::main event: line
0: @__main__:test_generator => sys_settrace_generator.py:65
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:67
7
### trace_handler::main event: return
0: @__main__:test_generator => sys_settrace_generator.py:65
1: @__main__:<module> => sys_settrace_generator.py:69
0: @__main__:test_generator => sys_settrace_generator.py:63
1: @__main__:<module> => sys_settrace_generator.py:67
Total traces executed: 54

View File

@ -1,5 +1,6 @@
print("Now comes the language constructions tests.")
# function
def test_func():
def test_sub_func():

View File

@ -125,6 +125,7 @@ key = binascii.unhexlify(
b"8b17a330a306a6fbcf51ba83563aed85a4f886fff1a22423748d83798c"
)
# Server
def instance0():
multitest.globals(IP=multitest.get_network_ip())

View File

@ -39,6 +39,7 @@ cert = binascii.unhexlify(
b"979b57f0b3"
)
# Server
def instance0():
multitest.globals(IP=multitest.get_network_ip())

View File

@ -4,6 +4,7 @@ import socket
PORT = 8000
# Server
def instance0():
multitest.globals(IP=multitest.get_network_ip())

View File

@ -5,6 +5,7 @@
# author: collinwinter@google.com (Collin Winter)
# n_queens function: Copyright 2009 Raymond Hettinger
# Pure-Python implementation of itertools.permutations().
def permutations(iterable, r=None):
"""permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)"""

View File

@ -33,6 +33,7 @@ aes_s_box_table = bytes((
))
# fmt: on
# multiplication of polynomials modulo x^8 + x^4 + x^3 + x + 1 = 0x11b
def aes_gf8_mul_2(x):
if x & 0x80:
@ -64,6 +65,7 @@ def aes_r_con(a):
##################################################################
# basic AES algorithm; see FIPS-197
# all inputs must be size 16
def aes_add_round_key(state, w):
for i in range(16):

View File

@ -55,6 +55,7 @@ set_and_print_calib(-511)
# restore existing calibration value
rtc.calibration(cal_tmp)
# Check register settings for wakeup
def set_and_print_wakeup(ms):
try:

View File

@ -3,6 +3,7 @@
import pyb
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")

View File

@ -28,7 +28,6 @@ def run_tests(pyb, test_dict):
for base_test, tests in sorted(test_dict.items()):
print(base_test + ":")
for test_file in tests:
# run MicroPython
if pyb is None:
# run on PC

View File

@ -17,6 +17,7 @@ for l in range(254, 259):
continue
print(var in g)
# calling a function with kwarg
def f(**k):
print(k)
@ -36,6 +37,7 @@ for l in range(254, 259):
except RuntimeError:
print("RuntimeError", l)
# hasattr, setattr, getattr
class A:
pass

View File

@ -1,5 +1,6 @@
# test deeply recursive generators
# simple "yield from" recursion
def gen():
yield from gen()
@ -10,6 +11,7 @@ try:
except RuntimeError:
print("RuntimeError")
# recursion via an iterator over a generator
def gen2():
for x in gen2():

View File

@ -7,6 +7,7 @@ import _thread
# the shared bytearray
ba = bytearray()
# main thread function
def th(n, lo, hi):
for repeat in range(n):

View File

@ -7,6 +7,7 @@ import _thread
# the shared dict
di = {"a": "A", "b": "B", "c": "C", "d": "D"}
# main thread function
def th(n, lo, hi):
for repeat in range(n):

View File

@ -4,6 +4,7 @@
import _thread
# the shared user class and instance
class User:
def __init__(self):
@ -14,6 +15,7 @@ class User:
user = User()
# main thread function
def th(n, lo, hi):
for repeat in range(n):

View File

@ -7,6 +7,7 @@ import _thread
# the shared list
li = list()
# main thread function
def th(n, lo, hi):
for repeat in range(n):

View File

@ -7,6 +7,7 @@ import _thread
# the shared set
se = set([-1, -2, -3, -4])
# main thread function
def th(n, lo, hi):
for repeat in range(n):

View File

@ -38,6 +38,7 @@ aes_s_box_table = bytes((
))
# fmt: on
# multiplication of polynomials modulo x^8 + x^4 + x^3 + x + 1 = 0x11b
def aes_gf8_mul_2(x):
if x & 0x80:
@ -80,6 +81,7 @@ def aes_r_con(a):
# using OCB, where the sequence is xored against the plaintext.
# Care must be taken to (almost) always choose a different IV.
# all inputs must be size 16
def aes_add_round_key(state, w):
for i in range(16):

View File

@ -8,6 +8,7 @@ except ImportError:
import time
import _thread
# function to check the interned string
def check(s, val):
assert type(s) == str

View File

@ -10,6 +10,7 @@ bβ = 3
βb = 4
print(α, αβγ, , βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
@ -18,6 +19,7 @@ def α(β, γ):
α(1, 2)
# class, method identifiers
class φ:
def __init__(self):