Fix error when using os.getlogin() without a tty