From 562bdee8110267f2861625f40aa403a72f000def Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sat, 4 Nov 2023 17:33:58 -0400 Subject: [PATCH] Fix compat.is_darwin This fixes compat.is_darwin to use sys.platform instead of os.name so that it is True on macOS systems instead of always being False. The deprecation rationale in compat.py is accordingly adjusted. Together with c01fe76, this largely addresses #1731. --- git/compat.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/git/compat.py b/git/compat.py index 545bf65b4..629be075a 100644 --- a/git/compat.py +++ b/git/compat.py @@ -36,17 +36,14 @@ # DEPRECATED attributes providing shortcuts to operating system checks based on os.name. # -# - is_win and is_posix are deprecated because it is clearer, and helps avoid bugs, to -# write out the os.name checks explicitly. For example, is_win is False on Cygwin, but -# is often assumed to be True. +# These are deprecated because it is clearer, and helps avoid bugs, to write out the +# os.name or sys.platform checks explicitly, especially in cases where it matters which +# is used. For example, is_win is False on Cygwin, but is often assumed True. To detect +# Cygwin, use sys.platform == "cygwin". (Also, in the past, is_darwin was unreliable.) # -# - is_darwin is deprecated because it is always False on all systems, as os.name is -# never "darwin". For macOS, you can check for sys.platform == "darwin". (As on other -# Unix-like systems, os.name == "posix" on macOS. This is also the case on Cygwin.) -# -is_win: bool = os.name == "nt" +is_win = os.name == "nt" is_posix = os.name == "posix" -is_darwin = os.name == "darwin" +is_darwin = sys.platform == "darwin" defenc = sys.getfilesystemencoding()