From 338a4839b9f73d00f964f899aa1dab226e0a6f3b Mon Sep 17 00:00:00 2001 From: Robert de Vries Date: Thu, 16 Apr 2026 23:04:06 +0200 Subject: [PATCH] Fix various review comments. - Missing import in _ffi/__init__.py - Updated docstring of t2b - Reverted change to Random.__del__() --- wolfcrypt/_ffi/__init__.pyi | 1 + wolfcrypt/_ffi/lib.pyi | 2 +- wolfcrypt/random.py | 2 +- wolfcrypt/utils.py | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/_ffi/__init__.pyi b/wolfcrypt/_ffi/__init__.pyi index f068df3..fd4cc63 100644 --- a/wolfcrypt/_ffi/__init__.pyi +++ b/wolfcrypt/_ffi/__init__.pyi @@ -1,4 +1,5 @@ import _cffi_backend +import _ffi.lib as lib ffi: _cffi_backend.FFI diff --git a/wolfcrypt/_ffi/lib.pyi b/wolfcrypt/_ffi/lib.pyi index 222a534..047e5cf 100644 --- a/wolfcrypt/_ffi/lib.pyi +++ b/wolfcrypt/_ffi/lib.pyi @@ -1,6 +1,6 @@ from _cffi_backend import FFI -from typing_extensions import TypeAlias +from typing import TypeAlias INVALID_DEVID: int diff --git a/wolfcrypt/random.py b/wolfcrypt/random.py index 5dc7505..4c4f312 100644 --- a/wolfcrypt/random.py +++ b/wolfcrypt/random.py @@ -47,7 +47,7 @@ class Random: def __del__(self) -> None: if self.native_object: try: - Random._delete(self.native_object) + self._delete(self.native_object) except AttributeError: # Can occur during interpreter shutdown pass diff --git a/wolfcrypt/utils.py b/wolfcrypt/utils.py index e30ef31..a1c7d37 100644 --- a/wolfcrypt/utils.py +++ b/wolfcrypt/utils.py @@ -29,7 +29,8 @@ def t2b(string: bytes | bytearray | memoryview | str) -> bytes: """ Converts text to binary. - Passes through bytes, bytearray, and memoryview unchanged. + Passes through bytes unchanged. + Objects of type bytearray or memoryview are converted to bytes. Encodes str to UTF-8 bytes. """ if isinstance(string, (bytes, bytearray, memoryview)):