From bfb830480c10606e48819733e0b37dd37e9c4992 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 7 Nov 2023 16:19:53 -0500 Subject: [PATCH] fix busio example; update some scripts for Python 3.12 --- docs/shared_bindings_matrix.py | 6 +++--- shared-bindings/busio/__init__.c | 9 ++++++--- tools/build_release_files.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index 4cc9409325..d865f6963d 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -170,7 +170,7 @@ def build_module_map(): search_identifier = ADDITIONAL_MODULES[module] else: search_identifier = "CIRCUITPY_" + module.lstrip("_").upper() - re_pattern = f"{re.escape(search_identifier)}\s*\??=\s*(.+)" + re_pattern = fr"{re.escape(search_identifier)}\s*\??=\s*(.+)" find_config = re.findall(re_pattern, configs) if not find_config: continue @@ -242,12 +242,12 @@ def get_repository_url(directory): with open(readme, "r") as fp: for line in fp.readlines(): if m := re.match( - "\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", + r"\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", line, ): path = m.group(1) break - if m := re.search("<(http[^>]+)>", line): + if m := re.search(r"<(http[^>]+)>", line): path = m.group(1) break if path is None: diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 776920385e..a0b5f687b5 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -59,12 +59,15 @@ //| from board import * //| //| i2c = busio.I2C(SCL, SDA) +//| i2c.try_lock() //| print(i2c.scan()) +//| i2c.unlock() //| i2c.deinit() //| -//| This example will initialize the the device, run -//| :py:meth:`~busio.I2C.scan` and then :py:meth:`~busio.I2C.deinit` the -//| hardware. The last step is optional because CircuitPython automatically +//| This example will initialize the the device, lock the I2C bus, run +//| :py:meth:`~busio.I2C.scan`, unlock the bus, +//| and then :py:meth:`~busio.I2C.deinit` the hardware. +//| The last step is optional because CircuitPython automatically //| resets hardware after a program finishes. //| //| Note that drivers will typically handle communication if provided the bus diff --git a/tools/build_release_files.py b/tools/build_release_files.py index 341ae2d67f..ce23f57e88 100755 --- a/tools/build_release_files.py +++ b/tools/build_release_files.py @@ -139,7 +139,7 @@ for board in build_boards: # Flush so we will see something before 10 minutes has passed. print(flush=True) - if (not build_all) and (language is LANGUAGE_FIRST) and (exit_status is 0): + if (not build_all) and (language == LANGUAGE_FIRST) and (exit_status == 0): try: with open( f"../ports/{board_info['port']}/{build_dir}/firmware.size.json", "r"