[Python-bugs-list] [Bug #124758] Bogus error message from os.getlogin()

noreply@sourceforge.net noreply@sourceforge.net
Wed, 6 Dec 2000 13:26:18 -0800


Bug #124758, was updated on 2000-Dec-06 12:39
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Open
Resolution: None
Bug Group: None
Priority: 3
Submitted by: Nobody
Assigned to : fdrake
Summary: Bogus error message from os.getlogin()

Details: This is happening under Mandrake 7.2, although judging from the Python source, it would happen under any flavor of Unix.

When the real getlogin() returns NULL, posix_error() is called with some old value in errno. This causes os.getlogin() to raise OSError with a 
bogus error message. A bit confusing  to see "OSError: [Errno 2] No such file or directory" when attempting os.getlogin()  :-)

Bob Alexander
bobalex@adc.rsv.ricoh.com

Follow-Ups:

Date: 2000-Dec-06 12:44
By: gvanrossum

Comment:
Fred, would you mind fixing this? It seems to be your code. I'd reset errno to zero before calling getlogin(). But maybe errno is never set by getlogin() and then it's bogus to call posix_error().

-------------------------------------------------------

Date: 2000-Dec-06 13:26
By: fdrake

Comment:
This is very strange -- how are you getting getlogin() to even fail?  The man page on my Mandrake 7.1 box says that if it returns null, there was an error getting the information, does not mention errno at all, but does document one particular errno result code under ERRORS.

I can easily patch it to be certain about the errno usage, but I'm not sure what's happening to cause the error (sounds like a system configuration problem; perhaps the fs utmp is on is full, so there's no record?).

Since this report was anonymous, I've just checked in the patch; hopefully it fixes everything in a reasonable way.  Modules/posixmodule.c revision 2.177.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=124758&group_id=5470