♻ Move internal variable for errors in `jsonable_encoder` to put related code closer (#4560)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Guillermo Quintana Pelayo 2022-08-26 15:16:44 +02:00 committed by GitHub
parent c8124496fc
commit a64387c3fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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)