Readline and unwanted filename completion

Simon Budig simon at ping-pong.budig
Sat Feb 2 16:09:58 EST 2002

In article <3c5b2c1f at>, Simon Budig wrote:
> Michael Hudson <mwh at> wrote:
>> Simon Budig <Simon.Budig at> writes:
>>> Something is broken with the completion of readline:
>> Well, I knew about it.  I don't regard it as a huge problem.
> Hmm. Imagine you are writing an interactive interpreter of a
> custom language to manipulate something non-file'ishes and
> suddenly the commandline starts completing *filenames*. I
> think this is a good showstopper...
>>> Is there an evil hack to avoid this?
>> Dunno.  Doubt it, somehow.  You'll need to look at the documentation
>> for readline, though.
> Well - I looked at the documentation for the readline-module, but that
> doesn't say anything about it. Maybe I should read the sources.

Ok, did that. Here is the Patch to fix this behaviour. It is against
Modules/readline.c from Python 2.1.2.

--- readline.c.orig	Sat Feb  2 21:44:09 2002
+++ readline.c	Sat Feb  2 22:01:16 2002
@@ -346,6 +346,9 @@
 		   lock released! */
 		save_tstate = PyThreadState_Swap(NULL);
+		/* Don't use the default filename completion if we
+		   have a custom completion function... */
+		rl_attempted_completion_over = 1;
 		r = PyObject_CallFunction(completer, "si", text, state);
 		if (r == NULL)
 			goto error;

I really would appreciate, if this gets incorporated in the regular
Python releases. Unfortunately I don't have an account at sourceforge
to submit this the proper way.


      Simon.Budig at

More information about the Python-list mailing list