mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
added parent_stmt to fast_parent_copy, which makes the method more reliable
This commit is contained in:
12
helpers.py
12
helpers.py
@@ -1,6 +1,7 @@
|
||||
import copy
|
||||
import weakref
|
||||
|
||||
from _compatibility import hasattr
|
||||
import parsing
|
||||
import evaluate
|
||||
import debug
|
||||
@@ -145,10 +146,9 @@ def fast_parent_copy(obj):
|
||||
def recursion(obj):
|
||||
new_obj = copy.copy(obj)
|
||||
new_elements[obj] = new_obj
|
||||
#print new_obj.__dict__
|
||||
|
||||
for key, value in new_obj.__dict__.items():
|
||||
#if key in ['_parent_stmt', 'parent_stmt', '_parent', 'parent']: print key, value
|
||||
if key in ['parent', '_parent']:
|
||||
if key in ['parent', '_parent', '_parent_stmt', 'parent_stmt']:
|
||||
continue
|
||||
if isinstance(value, list):
|
||||
new_obj.__dict__[key] = list_rec(value)
|
||||
@@ -161,6 +161,12 @@ def fast_parent_copy(obj):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if hasattr(obj, 'parent_stmt') and obj.parent_stmt is not None:
|
||||
try:
|
||||
new_obj.parent_stmt = weakref.ref(new_elements[obj.parent_stmt()])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return new_obj
|
||||
|
||||
def list_rec(list_obj):
|
||||
|
||||
Reference in New Issue
Block a user