src/eric7/DebugClients/Python/FlexCompleter.py

branch
eric7
changeset 11047
783fc3de315e
parent 10417
c6011e501282
child 11066
d71eab9be477
equal deleted inserted replaced
11046:478b4ce023dd 11047:783fc3de315e
49 """ 49 """
50 50
51 import builtins 51 import builtins
52 import keyword 52 import keyword
53 import re 53 import re
54 import sys
54 55
55 import __main__ 56 import __main__
56 57
57 __all__ = ["Completer"] 58 __all__ = ["Completer"]
58 59
80 @param namespace namespace for the completer 81 @param namespace namespace for the completer
81 @type dict 82 @type dict
82 @exception TypeError raised to indicate a wrong data structure of 83 @exception TypeError raised to indicate a wrong data structure of
83 the namespace object 84 the namespace object
84 """ 85 """
85 if namespace and not isinstance(namespace, dict): 86 if namespace and not isinstance(namespace, (dict, sys._getframe().f_locals.__class__)):
86 raise TypeError("namespace must be a dictionary") 87 raise TypeError("namespace must be a dictionary or since 3.13 a FrameLocalsProxy")
87 88
88 # Don't bind to namespace quite yet, but flag whether the user wants a 89 # Don't bind to namespace quite yet, but flag whether the user wants a
89 # specific namespace or to use __main__.__dict__. This will allow us 90 # specific namespace or to use __main__.__dict__. This will allow us
90 # to bind to __main__.__dict__ at completion time, not now. 91 # to bind to __main__.__dict__ at completion time, not now.
91 if namespace is None: 92 if namespace is None:
200 201
201 # get the content of the object, except __builtins__ 202 # get the content of the object, except __builtins__
202 words = set(dir(thisobject)) 203 words = set(dir(thisobject))
203 words.discard("__builtins__") 204 words.discard("__builtins__")
204 205
205 if hasattr(object, "__class__"): 206 if hasattr(thisobject, "__class__"):
206 words.add("__class__") 207 words.add("__class__")
207 words.update(get_class_members(thisobject.__class__)) 208 words.update(get_class_members(thisobject.__class__))
208 matches = [] 209 matches = []
209 n = len(attr) 210 n = len(attr)
210 if attr == "": 211 if attr == "":

eric ide

mercurial