Discussion:
readline problems
Magnus Lie Hetland
2002-12-28 21:09:19 UTC
Permalink
I'm having problems compiling in readline with the current CVS
version, using gcc 2.8.1 on Solaris (SunOS 5.9 Generic sun4u sparc).
The error is the following:

./Modules/readline.c: In function `setup_readline':
./Modules/readline.c:577: `rl_completion_append_character' undeclared
(first use in this function)
./Modules/readline.c:577: (Each undeclared identifier is reported only
once
./Modules/readline.c:577: for each function it appears in.)
./Modules/readline.c: In function `call_readline':
./Modules/readline.c:629: warning: implicit declaration of function
`rl_prep_terminal'

Is my version of readline too old? (Not sure exactly how old it is,
but the last year listed in the copyright notice is 1992 ;})

If the problem is that it is too old -- is there a reason why Python
isn't compatible with it anymore? (It worked before...)
--
Magnus Lie Hetland
http://hetland.org
Guido van Rossum
2002-12-29 02:11:41 UTC
Permalink
Post by Magnus Lie Hetland
I'm having problems compiling in readline with the current CVS
version, using gcc 2.8.1 on Solaris (SunOS 5.9 Generic sun4u sparc).
./Modules/readline.c:577: `rl_completion_append_character' undeclared
(first use in this function)
./Modules/readline.c:577: (Each undeclared identifier is reported only
once
./Modules/readline.c:577: for each function it appears in.)
./Modules/readline.c:629: warning: implicit declaration of function
`rl_prep_terminal'
Is my version of readline too old? (Not sure exactly how old it is,
but the last year listed in the copyright notice is 1992 ;})
If the problem is that it is too old -- is there a reason why Python
isn't compatible with it anymore? (It worked before...)
Strange. Modules/readline.c hasn't changed since late October. More
likely, your platform has downgraded (or it never worked, and you've
never noticed before).

Maybe you should upgrade to a newer version of readline? There's a
comment for revision 2.49 that seems to imply that you need GNU
readline 2.1 or higher, and that particular change did indeed do
something with the variable rl_completion_append_character.

I suggest upgrading to version 2.2 or 4.2 (both are in common use I
believe; 4.2 is the latests).

--Guido van Rossum (home page: http://www.python.org/~guido/)
Magnus Lie Hetland
2002-12-29 13:08:49 UTC
Permalink
Guido van Rossum <***@python.org>:
[snip]
Post by Guido van Rossum
Strange. Modules/readline.c hasn't changed since late October.
Not that strange, really -- up until now, I've been using Python 2.2.1
(in which readline.c does not use the two API functions mentioned),
and at times experimented with 2.3a0, but with no luck on readline.
Post by Guido van Rossum
More likely, your platform has downgraded (or it never worked, and
you've never noticed before).
The 2.2.1 version still works without a hitch.
Post by Guido van Rossum
Maybe you should upgrade to a newer version of readline?
That may be reasonable. I don't have direct control over the machine
in question, but I have requested such an upgrade. I assume things
will work just fine after that.

Just a thought: Could this use of these two API functions (or whatever
they are), rl_prep_terminal and rl_completion_append_characters, be
made optional as part of the compilation process? Autotools could
perhaps be able to figure out whether they are available? Just in the
interest of cross-platform compatibility and the like... (Although
supporting an ancient readline may not be that interesting, I suppose
:)

[snip]
Post by Guido van Rossum
I suggest upgrading to version 2.2 or 4.2 (both are in common use I
believe; 4.2 is the latests).
OK. Thanks for the help.
Post by Guido van Rossum
--Guido van Rossum (home page: http://www.python.org/~guido/)
--
Magnus Lie Hetland
http://hetland.org
Guido van Rossum
2002-12-29 15:31:24 UTC
Permalink
Post by Magnus Lie Hetland
Just a thought: Could this use of these two API functions (or whatever
they are), rl_prep_terminal and rl_completion_append_characters, be
made optional as part of the compilation process? Autotools could
perhaps be able to figure out whether they are available? Just in the
interest of cross-platform compatibility and the like... (Although
supporting an ancient readline may not be that interesting, I suppose
:)
If you want to write the autoconf deterction code for this, be my
guest. GNU readline makes it impossible to detect at compile-time
which version you have, otherwise I would have used #ifdef in the
source.

--Guido van Rossum (home page: http://www.python.org/~guido/)
Magnus Lie Hetland
2002-12-29 21:10:42 UTC
Permalink
Guido van Rossum <***@python.org>:
[snip]
Post by Guido van Rossum
If you want to write the autoconf deterction code for this, be my
guest.
I don't really know autoconf/readline well enough for this, I think.
Post by Guido van Rossum
GNU readline makes it impossible to detect at compile-time
which version you have, otherwise I would have used #ifdef in the
source.
I see.

Just out of curiosity: What is lost in using the old API?
Won't it work with more recent readline versions? Is there some
functionality/performance loss?
--
Magnus Lie Hetland
http://hetland.org
Guido van Rossum
2002-12-29 22:47:31 UTC
Permalink
Post by Magnus Lie Hetland
Post by Guido van Rossum
If you want to write the autoconf deterction code for this, be my
guest.
I don't really know autoconf/readline well enough for this, I think.
It would be a good learning experience. :-)
Post by Magnus Lie Hetland
Post by Guido van Rossum
GNU readline makes it impossible to detect at compile-time
which version you have, otherwise I would have used #ifdef in the
source.
I see.
Just out of curiosity: What is lost in using the old API?
Won't it work with more recent readline versions? Is there some
functionality/performance loss?
There's some functionality that's only available in the new APIs.

Here's the CVS entry.

----------------------------
revision 2.49
date: 2002/05/30 15:41:56; author: gvanrossum; state: Exp; lines: +1 -0
SF #558432: Prevent Annoying ' ' from readline (Holker Krekel).

readline in all python versions is configured
to append a 'space' character for a successful
completion. But for almost all python expressions
'space' is not wanted (see coding conventions PEP 8).
For example if you have a function 'longfunction'
and you type 'longf<TAB>' you get 'longfunction '
as a completion. note the unwanted space at the
end.

The patch fixes this behaviour by setting readline's
append_character to '\0' which means don't append
anything. This doesn't work with readline < 2.1
(AFAIK nowadays readline2.2 is in good use).

An alternative approach would be to make the
append_character
accessable from python so that modules like
the rlcompleter.py can set it to '\0'.

[Ed.: I think expecting readline >= 2.2 is fine. If a completer wants
another character they can append that to the keyword in the list.]
----------------------------

--Guido van Rossum (home page: http://www.python.org/~guido/)
Magnus Lie Hetland
2002-12-29 23:10:59 UTC
Permalink
Post by Guido van Rossum
Post by Magnus Lie Hetland
Post by Guido van Rossum
If you want to write the autoconf deterction code for this, be my
guest.
I don't really know autoconf/readline well enough for this, I think.
It would be a good learning experience. :-)
Heh. My learning experiences with autotools so far have been -- shall
we say, "interesting". :]

I'll take a look, but I expect I won't get far.

[snip]
Post by Guido van Rossum
There's some functionality that's only available in the new APIs.
Here's the CVS entry.
----------------------------
revision 2.49
date: 2002/05/30 15:41:56; author: gvanrossum; state: Exp; lines: +1 -0
SF #558432: Prevent Annoying ' ' from readline (Holker Krekel).
I see. This seems reasonable, I guess. (Although, if one uses readline
with Cmd, I would expect that ' ' is exactly what one wants, so
setting this from Python -- i.e. the "alternate approach" of the cvs
entry -- seems like a good idea...)
--
Magnus Lie Hetland
http://hetland.org
Magnus Lie Hetland
2002-12-29 23:50:31 UTC
Permalink
Magnus Lie Hetland <***@hetland.org>:
[snip]
Post by Magnus Lie Hetland
Post by Guido van Rossum
It would be a good learning experience. :-)
Heh. My learning experiences with autotools so far have been -- shall
we say, "interesting". :]
I'll take a look, but I expect I won't get far.
Wouldn't you know -- it wasn't really that hard:

AC_TRY_CPP([#include <readline/readline.h>],
have_readline=yes, have_readline=no)
if test $have_readline = yes
then
AC_EGREP_HEADER([extern int rl_completion_append_character;],
[readline/readline.h],
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1))
fi

After putting this somewhere in configure.in it should only be a
matter of inserting the #ifdef's you talked about, referring to
HAVE_RL_COMPLETION_APPEND_CHARACTER. (I assume rl_prep_terminal is
linked to rl_completion_append_character in terms of versions here.)
--
Magnus Lie Hetland
http://hetland.org
Magnus Lie Hetland
2002-12-30 02:14:38 UTC
Permalink
Please turn this into a real patch, upload to SF, and assign to me.
Will do. I'll only make a patch for configure.in -- OK? (I haven't
looked much on what would be needed in readline.c...)
But I don't have time for this myself -- so it won't make it into
2.3a1 unless you make a patch for readline.c too. :-(
Done. I have now submitted a new version of my configure.in patch
(just added a comment) and a patch to readline.c.

It seems to work -- I get the new completion behaviour with my new
readline library in Linux and the old behaviour with my old readline
library in Solaris.
--Guido van Rossum (home page: http://www.python.org/~guido/)
--
Magnus Lie Hetland
http://hetland.org
Guido van Rossum
2002-12-30 16:40:42 UTC
Permalink
Post by Magnus Lie Hetland
Please turn this into a real patch, upload to SF, and assign to me.
Will do. I'll only make a patch for configure.in -- OK? (I haven't
looked much on what would be needed in readline.c...)
But I don't have time for this myself -- so it won't make it into
2.3a1 unless you make a patch for readline.c too. :-(
Done. I have now submitted a new version of my configure.in patch
(just added a comment) and a patch to readline.c.
It seems to work -- I get the new completion behaviour with my new
readline library in Linux and the old behaviour with my old readline
library in Solaris.
Thanks, Magnus. I've applied this to Python 2.3. It should also be
applied to 2.2.3.

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

Loading...