[issue18766] IDLE: Autocomplete in editor doesn't work for un-imported modules

Terry J. Reedy report at bugs.python.org
Sun Aug 3 23:16:33 CEST 2014


Terry J. Reedy added the comment:

A least a manual (human) test is needed: a description of steps that do not work now and do work with a patch.

Currently, get_entity() is only called in one place in fetch_completions; it is not used anywhere else in idlelib. (Call_tips defines another get_entity().)  Its body should be moved inline at the call site. A variation that differs in the second line
            namespace = __main__.__dict__.copy()
            namespace.update(__main__.__builtins__.__dict__)
is already in-lined in the if-branch above.

We are trying to eliminate bare excepts: in idlelib -- #15313 -- not expand them or their use. Try blocks should only include the statement or statements that could raise the exception or exceptions caught. So the import, once inlined, should be inside try: except ImportError: return... .

I do not know what the existing try: except: is meant to catch, but it includes too much, as does the one that follows. That, however, should be a separate patch.

+            namespace = sys.modules.copy()
+            namespace.update(__main__.__dict__)
seems unnecessary. I think the following should work.
           namespace[name] = sys.modules[name]
A testcase would make sure either way.

----------
stage:  -> test needed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18766>
_______________________________________


More information about the Python-bugs-list mailing list