Skip to content

Commit 32d37aa

Browse files
committed
Revert to including path in chroot error message
1 parent 5bf2bcc commit 32d37aa

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

Lib/test/test_os/test_os.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,10 +4570,7 @@ def test_oserror_filename(self):
45704570
try:
45714571
func(name, *func_args)
45724572
except OSError as err:
4573-
if support.is_android and os.getuid() != 0 and func is getattr(os, 'chroot', None):
4574-
self.assertIsNone(err.filename, str(func))
4575-
else:
4576-
self.assertIs(err.filename, name, str(func))
4573+
self.assertIs(err.filename, name, str(func))
45774574
except UnicodeDecodeError:
45784575
pass
45794576
else:

Lib/test/test_os/test_posix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def test_getresgid(self):
107107
@unittest.skipUnless(hasattr(posix, 'setresuid'),
108108
'test needs posix.setresuid()')
109109
def test_setresuid(self):
110+
# Android blocks this function for non-root users regardless of the arguments.
110111
if support.is_android and os.getuid() != 0:
111112
self.assertRaises(PermissionError, posix.setresuid, -1, -1, -1)
112113
return
@@ -127,6 +128,7 @@ def test_setresuid_exception(self):
127128
@unittest.skipUnless(hasattr(posix, 'setresgid'),
128129
'test needs posix.setresgid()')
129130
def test_setresgid(self):
131+
# Android blocks this function for non-root users regardless of the arguments.
130132
if support.is_android and os.getuid() != 0:
131133
self.assertRaises(PermissionError, posix.setresgid, -1, -1, -1)
132134
return

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4418,7 +4418,7 @@ os_chroot_impl(PyObject *module, path_t *path)
44184418
// rather than returning a permission error.
44194419
if (getuid() != 0) {
44204420
errno = EPERM;
4421-
return posix_error();
4421+
return path_error(path);
44224422
}
44234423
#endif
44244424
int res;

0 commit comments

Comments
 (0)