[ python-Bugs-1404213 ] os.getlogin() goes **poof**

SourceForge.net noreply at sourceforge.net
Thu Jan 12 23:10:00 CET 2006


Bugs item #1404213, was opened at 2006-01-12 21:59
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1404213&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Jim Wilson (wilson1442)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.getlogin() goes **poof**

Initial Comment:
"python -c "import os; getlogin()" rears its ugly head
again.  It complains it can't open "<string>" (Python
2.4.1, FC4).

Strace confirms it:

open("<string>", ...)  = -1 ENOENT (No such file or ...
open("<string>", ...)  = -1 ENOENT ...
open("/usr/lib/python24.zip/<string>", ...) = -1 ...
open("/usr/lib/python2.4/<string>", ...) = -1 ...
open("/usr/lib/python2.4/plat-linux2/<string>", ... 
open("/usr/lib/python2.4/lib-tk/<string>", ...
open("/usr/lib/python2.4/lib-dynload/<string>", ...
open("/usr/lib/python2.4/site-packages/<string>", ... 
[<two more long obscure directories>/<string> snipped.]

I don't know what's in that "<string>" file, but it
surely must be important.


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

>Comment By: Georg Brandl (birkenfeld)
Date: 2006-01-12 23:10

Message:
Logged In: YES 
user_id=1188172

It is os.getlogin(), but the search for <string> doesn't
have to do anything with it.

As for why getlogin() is failing, consult your local manpage
for details what getlogin() is doing (wrong).

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

Comment By: Jim Wilson (wilson1442)
Date: 2006-01-12 22:58

Message:
Logged In: YES 
user_id=1191155

Actually, my diagnosis was meant to be jocular.  I don't
have a clue what's happening.  Someone else suggested using
strace when this problem was reported earlier.  Your
explanation makes perfect sense.

But ... that certainly narrows it down.  If it ain't
"os.getlogin()", that leaves only "import os;", right?

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

Comment By: Georg Brandl (birkenfeld)
Date: 2006-01-12 22:34

Message:
Logged In: YES 
user_id=1188172

Your diagnosis is incorrect. The system's getlogin() sets
errno 2, that is "No such file or directory". Thus
os.getlogin() raises an OSError with this description.

Python's "file name" for -c scripts is "<string>", and
because Python wants to give you a traceback with lines and
code context, it looks for the file "<string>". This has
nothing to do with getlogin.

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

Comment By: Jim Wilson (wilson1442)
Date: 2006-01-12 22:17

Message:
Logged In: YES 
user_id=1191155

Er...  Of course, I intended:

python -c "import os; os.getlogin()"

diagnostic output was from:

strace -e trace=open python -c "import os; os.getlogin()"

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1404213&group_id=5470


More information about the Python-bugs-list mailing list