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>
pull/10639/head
Jim Mussared 2023-02-02 11:51:48 +11:00
rodzic fe2a8332ff
commit 8b27482692
75 zmienionych plików z 208 dodań i 123 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -39,6 +39,7 @@ DAC2 = const(26)
# Helper functions # Helper functions
# Get a *rough* estimate of the current battery voltage # 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 # 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. # so it will still show a voltage.

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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) f6(1, 2, 3, 4, 5, 6)
# test compiling *x, **x, * args (currently unsupported at runtime) # test compiling *x, **x, * args (currently unsupported at runtime)
@micropython.viper @micropython.viper
def f(*x, **y): def f(*x, **y):

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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