From: Guillermo Quintana Pelayo <36505071+GuilleQP@users.noreply.github.com> Date: Fri, 26 Aug 2022 13:16:44 +0000 (+0200) Subject: ♻ Move internal variable for errors in `jsonable_encoder` to put related code closer... X-Git-Tag: 0.81.0~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a64387c3fc03120e3424fb12bfa64df8d949da43;p=thirdparty%2Ffastapi%2Ffastapi.git ♻ Move internal variable for errors in `jsonable_encoder` to put related code closer (#4560) Co-authored-by: Sebastián Ramírez --- diff --git a/fastapi/encoders.py b/fastapi/encoders.py index b1fde73ceb..6f571edb26 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)