Skip to content
Myr

Prevent multiline error message on invalid path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Taylor Payne · committed by Taylor Payne · parent e88c112 · Browse files · 3 files+12 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+12 added−2 removed

  • tests:+9 added−0 removed
  • other:+3 added−2 removed

3 files+12 added−2 removed

modified:src/click/types.py+1 added-1 removed
890 unmodified lines
891 ctx,892 )893 if not self.dir_okay and stat.S_ISDIR(st.st_mode):894 self.fail(895 _("{name} '{filename}' is a directory.").format(895 _("{name} {filename!r} is a directory.").format(896 name=self.name.title(), filename=format_filename(value)897 ),898 param,899 ctx,
191 unmodified lines
modified:tests/test_types.py+9 added
230 unmodified lines
231232def test_file_error_surrogates():233 message = FileError(filename="\udcff").format_message()234 assert message == "Could not open file '�': unknown error"235236237def test_path_type_with_esc_sequence():238 with pytest.raises(click.BadParameter) as exc_info:239 with tempfile.TemporaryDirectory(prefix=r"my\ndir") as tempdir:240 click.Path(dir_okay=False, resolve_path=True).convert(tempdir, None, None)241242 expected = "my\\\\ndir"243 assert expected in exc_info.value.message
modified:CHANGES.rst+2 added-1 removed
4 unmodified lines
56Unreleased78- Fix an issue with type hints for ``click.open_file()``. :issue:`2717`9- Fix issue where error message for invalid ``click.Path`` displays on10 multiple lines. :issue:`2697`1112Version 8.1.713-------------14
2 unmodified lines
17- Fix issue with regex flags in shell completion. :issue:`2581`18- Bash version detection issues a warning instead of an error. :issue:`2574`19- Fix issue with completion script for Fish shell. :issue:`2567`201921Version 8.1.622-------------2324Released 2023-07-18
1090 unmodified lines