Fix various review comments.

- Missing import in _ffi/__init__.py
- Updated docstring of t2b
- Reverted change to Random.__del__()
pull/100/head
Robert de Vries 2026-04-16 23:04:06 +02:00
parent 8448f41b42
commit 338a4839b9
4 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import _cffi_backend
import _ffi.lib as lib
ffi: _cffi_backend.FFI

View File

@ -1,6 +1,6 @@
from _cffi_backend import FFI
from typing_extensions import TypeAlias
from typing import TypeAlias
INVALID_DEVID: int

View File

@ -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

View File

@ -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)):