File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -587,11 +587,16 @@ def __create_proxy(instance: object):
587587 if DEV :
588588 print (f'[Reactive] create proxy: { instance } ' )
589589 patched_class = get_patched_class (instance )
590- proxy = patched_class ()
591- if isinstance (instance , dict ):
592- # NOTE: 根据测试,在 JSONEncoder 中,在对 dict 调用 c_make_encoder 编码时,
593- # 如果这里不随便填上点儿东西初始化,json.dumps 输出内容会为空 {}
594- cast (Any , dict ).__init__ (proxy , {None : None })
590+ try :
591+ proxy = patched_class ()
592+ if isinstance (instance , dict ):
593+ # NOTE: According to testing, in the JSONEncoder, when calling c_make_encoder to encode a dict,
594+ # if something is not initialized here casually, the output of json.dumps will be an empty {}.
595+ cast (Any , dict ).__init__ (proxy , {None : None })
596+ except Exception :
597+ # If the class supports passing in an instance of itself and directly returning it, then use this feature to bypass the __new__ method。
598+ # Because we don't know what parameters to fill in for __new__, we can only try to directly pass in an instance of itself.
599+ proxy = patched_class (instance )
595600 return record_new_reactive_obj (cast (object , instance ), proxy )
596601
597602
You can’t perform that action at this time.
0 commit comments