[Python-Dev] SWIG and rlcompleter

Michael Krasnyk miha at mpi-magdeburg.mpg.de
Mon Aug 15 08:22:10 CEST 2005


Hello all,

Recently I've found that rlcompleter does not work correctly with SWIG
generated classes.
In some cases dir(object) containes not only strings, but also type of
the object, smth like <class 'mywrapper.IClassPtr'>. 
And condition "word[:n] == attr" throws an exception.
Is it possible to solve this problem with following path?

--- cut ---
--- rlcompleter.py.org  2005-08-14 13:02:02.000000000 +0200
+++ rlcompleter.py      2005-08-14 13:18:59.000000000 +0200
@@ -136,8 +136,11 @@
         matches = []
         n = len(attr)
         for word in words:
-            if word[:n] == attr and word != "__builtins__":
-                matches.append("%s.%s" % (expr, word))
+            try:
+                if word[:n] == attr and word != "__builtins__":
+                    matches.append("%s.%s" % (expr, word))
+            except:
+                pass
         return matches

  def get_class_members(klass):
--- cut ---

Thanks in advance,
Michael Krasnyk



More information about the Python-Dev mailing list