Skip to content
Myr

Catch unicode errors as bad value.

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 1965509 · Browse files · 1 file+6 added−4 removed
This commit

State

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

Diff stats

1 file+6 added−4 removed

  • other:+6 added−4 removed

1 file+6 added−4 removed

modified:click/types.py+6 added-4 removed
1import os2import stat34from ._compat import open_stream, text_type, filename_to_ui, \5 get_filesystem_encoding, get_streerror, _get_argv_encoding5 get_filesystem_encoding, get_streerror, _get_argv_encoding, PY26from .exceptions import BadParameter7from .utils import safecall, LazyFile89
157 unmodified lines
167168 def convert(self, value, param, ctx):169 try:170 return int(value)171 except ValueError:171 except (ValueError, UnicodeError):172 self.fail('%s is not a valid integer' % value, param, ctx)173174 def __repr__(self):175 return 'INT'
60 unmodified lines
236237 def convert(self, value, param, ctx):238 try:239 return float(value)240 except ValueError:240 except (UnicodeError, ValueError):241 self.fail('%s is not a valid floating point value' %242 value, param, ctx)243244 def __repr__(self):
5 unmodified lines
250251 def convert(self, value, param, ctx):252 import uuid253 try:254 if PY2 and isinstance(value, text_type):255 value = value.encode('ascii')256 return uuid.UUID(value)255 except ValueError:257 except (UnicodeError, ValueError):258 self.fail('%s is not a valid UUID value' % value, param, ctx)259260 def __repr__(self):261 return 'UUID'
289 unmodified lines