From b004c8af199aa942a6c14fade64f267d6c7f7579 Mon Sep 17 00:00:00 2001 From: Yyonging Date: Sat, 27 Jun 2020 21:10:09 +0800 Subject: [PATCH] fix the #307 (#371) --- aiogram/types/fields.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aiogram/types/fields.py b/aiogram/types/fields.py index e0d5b892..022b9b72 100644 --- a/aiogram/types/fields.py +++ b/aiogram/types/fields.py @@ -1,5 +1,6 @@ import abc import datetime +import weakref __all__ = ('BaseField', 'Field', 'ListField', 'DateTimeField', 'TextField', 'ListOfLists') @@ -109,7 +110,9 @@ class Field(BaseField): and self.base_object is not None \ and not hasattr(value, 'base_object') \ and not hasattr(value, 'to_python'): - return self.base_object(conf={'parent': parent}, **value) + if not isinstance(parent, weakref.ReferenceType): + parent = weakref.ref(parent) + return self.base_object(conf={'parent':parent}, **value) return value