Skip to content

Fix bugs affecting exception wrapping in rmtree callback #1700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Treat false-seeming HIDE_* env var values as false
This changes how HIDE_WINDOWS_KNOWN_ERRORS and
HIDE_WINDOWS_FREEZE_ERRORS environment variables, if present, are
interpreted, so that values that strongly seem intuitivley to
represent falsehood now do.

Before, only the empty string was treated as false. Now:

- "0", "false", "no", and their case variants, as well as the empty
  string, are treated as false.

- The presence of leading and trailing whitespace in the value now
  longer changes the truth value it represents. For example,
  all-whitespace (e.g., a space) is treated as false.

- Values other than the above false values, and the recognized true
  values "1", "true", "yes", and their variants, are still treated
  as true, but issue a warning about how they are unrecognied.
  • Loading branch information
EliahKagan committed Oct 9, 2023
commit 333896b4447c56093fa4ae402a3d22491928ce29
10 changes: 8 additions & 2 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ def _read_env_flag(name: str, default: bool) -> bool:
name,
)

# FIXME: This should treat some values besides "" as expressing falsehood.
return bool(value)
adjusted_value = value.strip().lower()

if adjusted_value in {"", "0", "false", "no"}:
return False
if adjusted_value in {"1", "true", "yes"}:
return True
log.warning("%s has unrecognized value %r, treating as %r.", name, value, default)
return default


#: We need an easy way to see if Appveyor TCs start failing,
Expand Down
8 changes: 4 additions & 4 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@ def run_parse(value):
("true-seeming", "True"),
("true-seeming", "yes"),
("true-seeming", "YES"),
]
falsy_cases = [
("empty", ""),
("whitespace", " "),
("false-seeming", "0"),
("false-seeming", "false"),
("false-seeming", "False"),
("false-seeming", "no"),
("false-seeming", "NO"),
("whitespace", " "),
]
falsy_cases = [
("empty", ""),
]

for msg, env_var_value in truthy_cases:
Expand Down