[Python-Dev] _cursesmodule linking, and portability

Mark Favas m.favas@per.dem.csiro.au
Sun, 23 Jul 2000 23:39:52 +0800

Thomas Wouters wrote:
> On Sun, Jul 23, 2000 at 03:21:31PM +0300, Moshe Zadka wrote:
> > On Sun, 23 Jul 2000, Eric S. Raymond wrote:
> > > So I recommend trying to add has_key to the curses module interface in
> > > Python, conditionalized on whether you can pick it out of the local
> > > curses headers.
> > This sounds just like what Mark did. Or maybe I'm reading you wrong.
> I think what Eric means is moving the ncurses 'has_key' function into the
> cursesmodule directly, so that there is an implementation for it on all
> platforms. (Unsure if that's feasible, though.) Or if he doesn't, he doesn't
> realize that it's already conditional, and hence not too useful in
> cursesmodule -- you can't rely on it being there.
> How about a fake has_key for systems that have strict XPG4 or SVr4 curses,
> that assumes the terminal in question has a minimal set of function keys ?
> I'm thinking 'vt100' here, given the abundance of vt100(-derived) terminals,
> but a smaller set would be fine, too, I think.
> Oh, and perhaps an autoconf test on has_key is a better idea than a platform
> specific #ifdef -- if people port ncurses to that platform, they'd get
> has_key after all.

This seems to be the way to go. In a nutshell: from what Eric says,
has_key() is a needed functionality in the curses module/package. This
function is not supplied by the standard curses libraries on the Sun,
SGI and Compaq/DEC Unix platforms (and, I guess, any other platforms
that implement only the X/Open curses API). The code in _cursesmodule.c
as it currently stands has specific support for Sun and SGI, (and
compilation support for Compaq/DEC). For Sun and SGI, exposure of this
has_key() function at the Python level is #ifdef'ed out (and my patch
just adds Compaq/DEC to this set). If this functionality is indeed
vital, there should either be an equivalent written in Python present
(inside a try: - except: clause) in the curses package for those
platforms not providing it natively, or code for has_key() provided in
the _cursesmodule.c itself. And an autoconf test does indeed seem the
best way to determine whether has_key() exists, rather than platform

Alternatively, support for Sun, SGI, etc should be dropped from the
_cursesmodule.c code and a comment to that effect made in Setup.in. The
current comment specifies only that the System V version of curses
("often supplied by the ncurses library") is required.
Email  - m.favas@per.dem.csiro.au        Mark C Favas
Phone  - +61 8 9333 6268, 0418 926 074   CSIRO Exploration & Mining
Fax    - +61 8 9383 9891                 Private Bag No 5, Wembley
WGS84  - 31.95 S, 115.80 E               Western Australia 6913