[Python-Dev] SWIG and rlcompleter

Guido van Rossum gvanrossum at gmail.com
Mon Aug 15 19:11:24 CEST 2005


(1) Please use the SF patch manager.

(2) Please don't propose adding more bare "except:" clauses to the
standard library.

(3) I think a better patch is to use str(word)[:n] instead of word[:n].

On 8/14/05, Michael Krasnyk <miha at mpi-magdeburg.mpg.de> wrote:
> 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
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
> 


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list