Skip to content

Commit dd73903

Browse files
committed
gh-152936: Use posix_error for Android checks
1 parent f7effcf commit dd73903

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
:func:`os.chroot`, :func:`os.initgroups`, :func:`os.setegid`,
2-
:func:`os.seteuid`, :func:`os.setgid`, :func:`os.setregid`,
3-
:func:`os.setresgid`, :func:`os.setresuid`, :func:`os.setreuid`,
4-
:func:`os.setuid`, and :func:`socket.sethostname` are now available on
5-
Android. Calling them without sufficient privileges now raises
1+
:func:`os.chroot`, :func:`os.initgroups`, :func:`os.setegid`,
2+
:func:`os.seteuid`, :func:`os.setgid`, :func:`os.setregid`,
3+
:func:`os.setresgid`, :func:`os.setresuid`, :func:`os.setreuid`,
4+
:func:`os.setuid`, and :func:`socket.sethostname` are now available on
5+
Android. Calling them without sufficient privileges now raises
66
:exc:`PermissionError` instead of the functions being unavailable.

Modules/posixmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,7 +4405,7 @@ os_chroot_impl(PyObject *module, path_t *path)
44054405
// rather than returning a permission error.
44064406
if (getuid() != 0) {
44074407
errno = EPERM;
4408-
return path_error(path);
4408+
return posix_error();
44094409
}
44104410
#endif
44114411
int res;
@@ -9868,7 +9868,7 @@ os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid)
98689868
// rather than returning a permission error.
98699869
if (getuid() != 0) {
98709870
errno = EPERM;
9871-
return PyErr_SetFromErrno(PyExc_OSError);
9871+
return posix_error();
98729872
}
98739873
#endif
98749874
const char *username = PyBytes_AS_STRING(oname);

0 commit comments

Comments
 (0)