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
Provenance
- Commit
fab5356- Tree
d47a577- Author
Markus Unterwaditzer <markus@unterwaditzer.net>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent
159d0e5
3 files changed+37 added−20 removed
modified:click/types.py+20 added-20 removed
416 unmodified lines417 self.path_type,418 filename_to_ui(value)419 ), param, ctx)420 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)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)441 442 return self.coerce_path_result(rv)443 444 106 unmodified linesmodified:tests/test_arguments.py+11 added
104 unmodified lines105 assert result.output == 'Hey!'106 assert result.exit_code == 0107 108 109+def 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)114+115+ result = runner.invoke(foo, ['-'])116+ assert result.output == '-\n'117+ assert result.exit_code == 0118+119+120 def test_file_atomics(runner):121 @click.command()122 @click.argument('output', type=click.File('wb', atomic=True))123 def inout(output):166 unmodified linesmodified:CHANGES+6 added
1 unmodified line2 ===============3 4 This contains all major version changes between Click releases.5 6+Version 6.57+8+(bugfix release; not yet released)9+10+- Fix bug in `click.Path` where it would crash when passed a `-`. See #551.11+12 Version 6.413 -----------14 15 (bugfix release; released on March 24th 2016)324 unmodified lines