doc: improve explanation of return values
It is misleading to say that None is returned because the uid is unreliable. That implies that a uid of uknown integrity was retrieved. More accurately, and across all platforms, None indicates that no such id was determined.
This commit is contained in:
parent
f9aa628bd9
commit
af4ebebf44
|
@ -315,9 +315,9 @@ def safe_isclass(obj: object) -> bool:
|
||||||
|
|
||||||
def get_user_id() -> int | None:
|
def get_user_id() -> int | None:
|
||||||
"""Return the current process's real user id or None if it cannot be
|
"""Return the current process's real user id or None if it cannot be
|
||||||
retrieved reliably.
|
determined.
|
||||||
|
|
||||||
:return: The user id or None
|
:return: The user id or None if it could not be determined.
|
||||||
"""
|
"""
|
||||||
# mypy follows the version and platform checking expectation of PEP 484:
|
# mypy follows the version and platform checking expectation of PEP 484:
|
||||||
# https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=platform#python-version-and-system-platform-checks
|
# https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=platform#python-version-and-system-platform-checks
|
||||||
|
@ -328,7 +328,7 @@ def get_user_id() -> int | None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
# On other platforms, a return value of -1 is assumed to indicate that
|
# On other platforms, a return value of -1 is assumed to indicate that
|
||||||
# the current process's real user id cannot be retrieved reliably.
|
# the current process's real user id cannot be determined.
|
||||||
UNRELIABLE = -1
|
UNRELIABLE = -1
|
||||||
uid = os.getuid()
|
uid = os.getuid()
|
||||||
return uid if uid != UNRELIABLE else None
|
return uid if uid != UNRELIABLE else None
|
||||||
|
|
Loading…
Reference in New Issue