Skip to content
Myr

Fix UnboundLocalError in click.Path

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

* Fix UnboundLocalError in click.Path Fix #551 * Add changelog

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent 159d0e5 · Browse files · 3 files+37 added−20 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+37 added−20 removed

  • tests:+11 added−0 removed
  • other:+26 added−20 removed

3 files+37 added−20 removed

modified:click/types.py+20 added-20 removed
416 unmodified lines
417 self.path_type,418 filename_to_ui(value)419 ), param, ctx)420421 if not self.file_okay and stat.S_ISREG(st.st_mode):422 self.fail('%s "%s" is a file.' % (423 self.path_type,424 filename_to_ui(value)425 ), param, ctx)426 if not self.dir_okay and stat.S_ISDIR(st.st_mode):427 self.fail('%s "%s" is a directory.' % (428 self.path_type,429 filename_to_ui(value)430 ), param, ctx)431 if self.writable and not os.access(value, os.W_OK):432 self.fail('%s "%s" is not writable.' % (433 self.path_type,434 filename_to_ui(value)435 ), param, ctx)436 if self.readable and not os.access(value, os.R_OK):437 self.fail('%s "%s" is not readable.' % (438 self.path_type,439 filename_to_ui(value)440 ), param, ctx)421 if not self.file_okay and stat.S_ISREG(st.st_mode):422 self.fail('%s "%s" is a file.' % (423 self.path_type,424 filename_to_ui(value)425 ), param, ctx)426 if not self.dir_okay and stat.S_ISDIR(st.st_mode):427 self.fail('%s "%s" is a directory.' % (428 self.path_type,429 filename_to_ui(value)430 ), param, ctx)431 if self.writable and not os.access(value, os.W_OK):432 self.fail('%s "%s" is not writable.' % (433 self.path_type,434 filename_to_ui(value)435 ), param, ctx)436 if self.readable and not os.access(value, os.R_OK):437 self.fail('%s "%s" is not readable.' % (438 self.path_type,439 filename_to_ui(value)440 ), param, ctx)441442 return self.coerce_path_result(rv)443444
106 unmodified lines
modified:tests/test_arguments.py+11 added
104 unmodified lines
105 assert result.output == 'Hey!'106 assert result.exit_code == 0107108109def test_path_args(runner):110 @click.command()111 @click.argument('input', type=click.Path(dir_okay=False, allow_dash=True))112 def foo(input):113 click.echo(input)114115 result = runner.invoke(foo, ['-'])116 assert result.output == '-\n'117 assert result.exit_code == 0118119120def test_file_atomics(runner):121 @click.command()122 @click.argument('output', type=click.File('wb', atomic=True))123 def inout(output):
166 unmodified lines
modified:CHANGES+6 added
1 unmodified line
2===============34This contains all major version changes between Click releases.56Version 6.578(bugfix release; not yet released)910- Fix bug in `click.Path` where it would crash when passed a `-`. See #551.1112Version 6.413-----------1415(bugfix release; released on March 24th 2016)
324 unmodified lines