From 4ac1f51e0109246b03badba2c66e09e4a266aed3 Mon Sep 17 00:00:00 2001 From: cobycloud <25079070+cobycloud@users.noreply.github.com> Date: Mon, 13 Oct 2025 05:25:28 -0500 Subject: [PATCH] fix: support older orjson without serialize bytes --- pkgs/standards/tigrbl/tigrbl/response/shortcuts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/standards/tigrbl/tigrbl/response/shortcuts.py b/pkgs/standards/tigrbl/tigrbl/response/shortcuts.py index 03aa6e0c5..8e4c13770 100644 --- a/pkgs/standards/tigrbl/tigrbl/response/shortcuts.py +++ b/pkgs/standards/tigrbl/tigrbl/response/shortcuts.py @@ -29,12 +29,15 @@ def _json_default(value: Any) -> Any: try: import orjson as _orjson + _ORJSON_OPTIONS = _orjson.OPT_NON_STR_KEYS | _orjson.OPT_SERIALIZE_NUMPY + _OPT_SERIALIZE_BYTES = getattr(_orjson, "OPT_SERIALIZE_BYTES", None) + if _OPT_SERIALIZE_BYTES is not None: + _ORJSON_OPTIONS |= _OPT_SERIALIZE_BYTES + def _dumps(obj: Any) -> bytes: return _orjson.dumps( obj, - option=_orjson.OPT_NON_STR_KEYS - | _orjson.OPT_SERIALIZE_NUMPY - | _orjson.OPT_SERIALIZE_BYTES, + option=_ORJSON_OPTIONS, default=_json_default, ) except Exception: # pragma: no cover - fallback