[Python-checkins] r63094 - in python/trunk: Doc/library/rlcompleter.rst Lib/rlcompleter.py Misc/NEWS

georg.brandl python-checkins at python.org
Sun May 11 23:03:43 CEST 2008


Author: georg.brandl
Date: Sun May 11 23:03:42 2008
New Revision: 63094

Log:
- #2250: Exceptions raised during evaluation of names in rlcompleter's
  ``Completer.complete()`` method are now caught and ignored.



Modified:
   python/trunk/Doc/library/rlcompleter.rst
   python/trunk/Lib/rlcompleter.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Doc/library/rlcompleter.rst
==============================================================================
--- python/trunk/Doc/library/rlcompleter.rst	(original)
+++ python/trunk/Doc/library/rlcompleter.rst	Sun May 11 23:03:42 2008
@@ -61,5 +61,6 @@
    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.
 

Modified: python/trunk/Lib/rlcompleter.py
==============================================================================
--- python/trunk/Lib/rlcompleter.py	(original)
+++ python/trunk/Lib/rlcompleter.py	Sun May 11 23:03:42 2008
@@ -127,7 +127,10 @@
         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__')

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sun May 11 23:03:42 2008
@@ -23,6 +23,9 @@
 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.


More information about the Python-checkins mailing list