mirror of
https://github.com/python/cpython.git
synced 2026-02-13 19:04:37 +00:00
gh-139322: Reenable test_os.test_getlogin() (#139498)
Fix also getlogin() errno.
This commit is contained in:
parent
fb114cf497
commit
4e7e2dd043
3 changed files with 10 additions and 5 deletions
|
|
@ -3197,13 +3197,16 @@ def test_spawnvpe_invalid_env(self):
|
|||
self._test_invalid_env(os.spawnvpe)
|
||||
|
||||
|
||||
# The introduction of this TestCase caused at least two different errors on
|
||||
# *nix buildbots. Temporarily skip this to let the buildbots move along.
|
||||
@unittest.skip("Skip due to platform/environment differences on *NIX buildbots")
|
||||
@unittest.skipUnless(hasattr(os, 'getlogin'), "test needs os.getlogin")
|
||||
class LoginTests(unittest.TestCase):
|
||||
def test_getlogin(self):
|
||||
user_name = os.getlogin()
|
||||
try:
|
||||
user_name = os.getlogin()
|
||||
except OSError as exc:
|
||||
if exc.errno in (errno.ENOTTY, errno.ENXIO):
|
||||
self.skipTest(str(exc))
|
||||
else:
|
||||
raise
|
||||
self.assertNotEqual(len(user_name), 0)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Fix :func:`os.getlogin` error handling: fix the error number. Patch by
|
||||
Victor Stinner.
|
||||
|
|
@ -9605,7 +9605,7 @@ os_getlogin_impl(PyObject *module)
|
|||
int err = getlogin_r(name, sizeof(name));
|
||||
if (err) {
|
||||
int old_errno = errno;
|
||||
errno = -err;
|
||||
errno = err;
|
||||
posix_error();
|
||||
errno = old_errno;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue