Skip to content

Commit

Permalink
Fix compat.is_darwin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EliahKagan committed Nov 4, 2023
1 parent c01fe76 commit 562bdee
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 562bdee

Please sign in to comment.