Skip to content

Commit 8c364e9

Browse files
committed
Merge branch 'patch' of github.com:neolooong/mongoengine into neolooong-patch
2 parents e5ec680 + e311280 commit 8c364e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mongoengine/base/datastructures.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ def __init__(self, list_items, instance, name):
113113
BaseDocument = _import_class("BaseDocument")
114114

115115
if isinstance(instance, BaseDocument):
116-
self._instance = weakref.proxy(instance)
116+
if isinstance(instance, weakref.ProxyTypes):
117+
self._instance = instance
118+
else:
119+
self._instance = weakref.proxy(instance)
117120
self._name = name
118121
super().__init__(list_items)
119122

@@ -188,7 +191,10 @@ def _mark_as_changed(self, key=None):
188191
class EmbeddedDocumentList(BaseList):
189192
def __init__(self, list_items, instance, name):
190193
super().__init__(list_items, instance, name)
191-
self._instance = instance
194+
if isinstance(instance, weakref.ProxyTypes):
195+
self._instance = instance
196+
else:
197+
self._instance = weakref.proxy(instance)
192198

193199
@classmethod
194200
def __match_all(cls, embedded_doc, kwargs):

0 commit comments

Comments
 (0)