]> granicus.if.org Git - python/commitdiff
- #2250: Exceptions raised during evaluation of names in rlcompleter's
authorGeorg Brandl <georg@python.org>
Sun, 11 May 2008 21:03:42 +0000 (21:03 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 11 May 2008 21:03:42 +0000 (21:03 +0000)
  ``Completer.complete()`` method are now caught and ignored.

Doc/library/rlcompleter.rst
Lib/rlcompleter.py
Misc/NEWS

index b882cb0e9bbaf87d1ca21a470cd1c6e1fbc69df3..6816d391049869153a411f7c25e0d0ce0970fc61 100644 (file)
@@ -61,5 +61,6 @@ Completer objects have the following method:
    If called for a dotted name, it will try to evaluate anything without obvious
    side-effects (functions will not be evaluated, but it can generate calls to
    :meth:`__getattr__`) up to the last part, and find matches for the rest via the
-   :func:`dir` function.
+   :func:`dir` function.  Any exception raised during the evaluation of the 
+   expression is caught, silenced and :const:`None` is returned.
 
index a2d5fe6a8f00719f411646be3760b730ba20e247..36965e6eecc795c555a46c4f9d008c11d5ed2bc8 100644 (file)
@@ -127,7 +127,10 @@ class Completer:
         if not m:
             return []
         expr, attr = m.group(1, 3)
-        object = eval(expr, self.namespace)
+        try:
+            object = eval(expr, self.namespace)
+        except Exception:
+            return []
         words = dir(object)
         if hasattr(object,'__class__'):
             words.append('__class__')
index 4fd972a1fa5ce6ad49e9860db710e3140ed7e305..f843f2a1601a755e9e2ed58381a6add221edbd29 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,9 @@ Extension Modules
 Library
 -------
 
+- #2250: Exceptions raised during evaluation of names in rlcompleter's
+  ``Completer.complete()`` method are now caught and ignored.
+
 - #2659: Added ``break_on_hyphens`` option to textwrap TextWrapper class.
 
 - The mhlib module has been deprecated for removal in Python 3.0.