mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 15:24: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 copy
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
|
from _compatibility import hasattr
|
||||||
import parsing
|
import parsing
|
||||||
import evaluate
|
import evaluate
|
||||||
import debug
|
import debug
|
||||||
@@ -145,10 +146,9 @@ def fast_parent_copy(obj):
|
|||||||
def recursion(obj):
|
def recursion(obj):
|
||||||
new_obj = copy.copy(obj)
|
new_obj = copy.copy(obj)
|
||||||
new_elements[obj] = new_obj
|
new_elements[obj] = new_obj
|
||||||
#print new_obj.__dict__
|
|
||||||
for key, value in new_obj.__dict__.items():
|
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', '_parent_stmt', 'parent_stmt']:
|
||||||
if key in ['parent', '_parent']:
|
|
||||||
continue
|
continue
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
new_obj.__dict__[key] = list_rec(value)
|
new_obj.__dict__[key] = list_rec(value)
|
||||||
@@ -161,6 +161,12 @@ def fast_parent_copy(obj):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
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
|
return new_obj
|
||||||
|
|
||||||
def list_rec(list_obj):
|
def list_rec(list_obj):
|
||||||
|
|||||||
Reference in New Issue
Block a user