[Python-Dev] test_posix failures?

Thomas Wouters thomas@xs4all.net
Mon, 17 Mar 2003 20:57:53 +0100


On Mon, Mar 17, 2003 at 02:39:43PM -0500, Barry A. Warsaw wrote:

> test_posix fails for me in current CVS:

> narrowed down to posix.getlogin().  FTR I'm on RH7.3.

> Here's the fun part <wink>: this succeeds if running in an xterm, but
> fails if running in a XEmacs 21.4.11 shell buffer.  I tried it with
> Emacs 21.2 as well and it also fails there.  A little C program
> calling getlogin() gives the same results.  It also fails in a XEmacs
> compilation buffer.

> So the os.isatty() test isn't enough.  This returns True in all three
> shells but getlogin() still fails.  The weird thing is that I've never
> seen failures here before and I do this type of testing all the time.

Getlogin isn't guaranteed to work even when running in a terminal. Using the
excellent 'screen' tool, you can 'log out' your session (on a per-shell
basis.) Being 'logged in' just means there is an entry for your terminal in
/var/run/utmp (although the location of the 'utmp' file is
system-dependent.) Observe:

>>> os.getlogin()
'thomas'
^AL
This window is no longer logged in.
>>> os.getlogin()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 2] No such file or directory
>>> 

Inbetween the two 'getlogin' calls, I hit '^A', 'L', and screen told me
"This window is no longer logged in." And look, ma, no login. Note that
there isn't really a portable way to write utmp (screen jumps through hoops,
and disables the ability if it can't figure out how to do it) and it might
need special privileges, so we can't just add a utmp entry to check against.

I'm guessing you updated your (X)Emacs, your libc or something else on your
platform that causes this problem for you, Barry. Perhaps the 'getlogin'
test needs a 'utmp' resource ? :-)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!