rlcompleter not calling __getattr__ on [ ]
Fernando Pérez
fperez528 at yahoo.com
Mon Apr 22 13:39:24 EDT 2002
Jaco Schieke wrote:
>> I was going to ask the same thing as I'm inclined to think this is a bug:
>> readline has '[' and ']' as part of its internal list of word delimiters,
>> so when you do
>> a[0].<tab>
>> it breaks the word at ']' and sees a bare '.', hence the completions you
>> get. So far so good.
>>
>> BUT: if you change the list of delimiters (with readline.set_delimiters())
>> to remove '[' and ']', the problem persists. That's the part I think to be
>> a bug (I could be wrong, but I'd like to understand why if that's the
>> case). At this point it shouldn't break at ']' anymore, and the completion
>> should be done on the full 'a[0]'. I put print statements in the
>> rlcompleter code to see this and indeed, readline _is_ breaking on ']' even
>> after removing the character from the list of delimiters.
>>
>> Unfortunately the completion code is in C and I don't have the sources
>> around, so I haven't had the chance to take a look at this.
>>
>> I'd love to hear from someone who knows the code as to this behavior really
>> is a bug or not before shooting off to SF and looking like an idiot :)
>>
>> Cheers,
>>
>> f.
>
>
> Looks like the regexp in rlcompleter that searches the string does not
> work correctly. After changing the line
>
>> m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
>
> to
>
>> m = re.match(r"([\w\[\]]+(\.[\w\[\]]+)*)\.(\w*)", text)
>
> it matched on the brackets too and could get to the objects. I also
> had to change the delimiters to exclude [].
Nice! I didn't think to look there as I assumed thiss part was happening in
the C part of readline. Do you care to submit a bug report with this one-line
patch to SourceForge? I'd really like to have rlcompleter in 2.3 have this
fixed (it already has a patch I sent in earlier for another problem) That way
I could stop shipping a separate patched version with my own project.
If you can't/won't do it let me know and I can send the patch in.
Cheers,
f.
More information about the Python-list
mailing list