From 3eeb3ab884b6e456faa2a055ca693fed6b427c74 Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Mon, 26 Feb 2024 15:53:23 +0100 Subject: [PATCH] [fix] Python3.8 custom 'cache' decorator --- CHANGELOG.md | 6 ++++++ speculos/mcu/display.py | 7 ++++++- speculos/mcu/nbgl.py | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad3de895..71f52004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.1] - 2-24-02-26 + +### Fixed + +- Specific `cache` mechanism for Python3.8 (`functools.cache` does not exists yet) + ## [0.7.0] - 2024-02-26 ### Changed diff --git a/speculos/mcu/display.py b/speculos/mcu/display.py index fc7f6365..7ecb39ef 100644 --- a/speculos/mcu/display.py +++ b/speculos/mcu/display.py @@ -2,7 +2,12 @@ import io from abc import ABC, abstractmethod -from functools import cache +try: + from functools import cache +except ImportError: + # `functools.cache` does not exists on Python3.8 + from functools import lru_cache + cache = lru_cache(maxsize=None) from PIL import Image from socket import socket from typing import Any, Dict, IO, List, Optional, Tuple, Union diff --git a/speculos/mcu/nbgl.py b/speculos/mcu/nbgl.py index 079bd2bd..8d8cd2f3 100644 --- a/speculos/mcu/nbgl.py +++ b/speculos/mcu/nbgl.py @@ -3,7 +3,12 @@ import sys from construct import Struct, Int8ul, Int16ul from enum import IntEnum -from functools import cache +try: + from functools import cache +except ImportError: + # `functools.cache` does not exists on Python3.8 + from functools import lru_cache + cache = lru_cache(maxsize=None) from typing import Tuple from .display import FrameBuffer, GraphicLibrary