File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -132,16 +132,11 @@ def json_unpacker(s: str | bytes) -> t.Any:
132132 _default_packer_unpacker = "json" , "json"
133133 _default_pack_unpack = (json_packer , json_unpacker )
134134else :
135+ import functools
135136
136- def orjson_packer (obj : t .Any ) -> bytes :
137- """Convert a json object to a bytes using orjson with a fallback to json_packer."""
138- try :
139- return orjson .dumps (
140- obj , default = json_default , option = orjson .OPT_NAIVE_UTC | orjson .OPT_UTC_Z
141- )
142- except (TypeError , ValueError ):
143- return json_packer (obj )
144-
137+ orjson_packer = functools .partial (
138+ orjson .dumps , default = json_default , option = orjson .OPT_NAIVE_UTC | orjson .OPT_UTC_Z
139+ )
145140 orjson_unpacker = orjson .loads
146141 _default_packer_unpacker = "orjson" , "orjson"
147142 _default_pack_unpack = (orjson_packer , orjson_unpacker )
You can’t perform that action at this time.
0 commit comments