From a64387c3fc03120e3424fb12bfa64df8d949da43 Mon Sep 17 00:00:00 2001 From: Guillermo Quintana Pelayo <36505071+GuilleQP@users.noreply.github.com> Date: Fri, 26 Aug 2022 15:16:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Move=20internal=20variable=20for=20?= =?UTF-8?q?errors=20in=20`jsonable=5Fencoder`=20to=20put=20related=20code?= =?UTF-8?q?=20closer=20(#4560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sebastián Ramírez --- fastapi/encoders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi/encoders.py b/fastapi/encoders.py index b1fde73ceb7fc..6f571edb261d7 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -137,10 +137,10 @@ def jsonable_encoder( if isinstance(obj, classes_tuple): return encoder(obj) - errors: List[Exception] = [] try: data = dict(obj) except Exception as e: + errors: List[Exception] = [] errors.append(e) try: data = vars(obj)