diff --git a/pylib/anki/_backend/__init__.py b/pylib/anki/_backend/__init__.py index d0c23045d..a54dae3c1 100644 --- a/pylib/anki/_backend/__init__.py +++ b/pylib/anki/_backend/__init__.py @@ -92,10 +92,11 @@ class RustBackend(RustBackendGenerated): return self._db_command(dict(kind="rollback")) def _db_command(self, input: Dict[str, Any]) -> Any: + bytes_input = to_json_bytes(input) try: - return from_json_bytes(self._backend.db_command(to_json_bytes(input))) + return from_json_bytes(self._backend.db_command(bytes_input)) except Exception as e: - err_bytes = bytes(e.args[0]) + err_bytes = e.args[0] err = backend_pb2.BackendError() err.ParseFromString(err_bytes) raise backend_exception_to_pylib(err)