Version: 2.1 (using 4.1.1 (KDE 4.1.1), Kubuntu packages) Compiler: cc OS: Linux (i686) release 2.6.26-5-generic Originally from https:/launchpad.net/bugs/155508 Python's os.getlogin() function fails when it is runs under Konsole/any embedded Konsole. It does not fail under virtual consoles, xterm, or gnome's terminal. To reproduce, enter the following in Konsole: python import os; os.getlogin() This will result in: Traceback (most recent call last): File "<stdin>", line 1, in ? OSError: [Errno 2] No such file or directory Expected result would be for your username to be returned.
Hi, This appears to relate to the fact that Konsole does not update utmp when it creates a new session. IIRC this was disabled in the lead-up to KDE 4.0 because of problems in the kpty library which I should really fix. In gnome-terminal you can see the same result if the "Update login records when command is launched" option is unchecked in the 'Title and Command' tab in the settings dialog.
As a side note, there is a bug in Konsole here but even so os.getlogin() ought to fail more gracefully, since it is easily possible for a terminal not to update the login records.
With KDE 4.6.x it works in Konsole/yakuake/konq.