Simon Budig's patch (posted by me):

[ #513235 ] prevent readline filename completion
diff --git a/Modules/readline.c b/Modules/readline.c
index fa4fc06..9b4d952 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -460,6 +460,9 @@
 		   lock released! */
 		save_tstate = PyThreadState_Swap(NULL);
 		PyEval_RestoreThread(completer_tstate);
+		/* 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;