console.py 585 B

1234567891011121314151617
  1. """The scripts' console output: undecodable path names and failed removals, printed readably."""
  2. from __future__ import annotations
  3. import io
  4. import sys
  5. def tolerate_undecodable_names() -> None:
  6. """Make stdout print an undecodable path name as escapes instead of raising."""
  7. if isinstance(sys.stdout, io.TextIOWrapper):
  8. sys.stdout.reconfigure(errors="backslashreplace")
  9. def removal_failure_detail(error: OSError) -> object:
  10. """The operator-readable reason a tree removal failed."""
  11. return str(error) if error.strerror or not error.args else error.args[0]