Skip to content
Myr

Bugfix: Make click.progressbar work with codecs.open files

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

- codecs.open returns a StreamReaderWriter when used with encoding, this object doesn't have a `__len__` attribute, so calling the `len` function on it result in an `AttributeError` instead of a `TypeError` - this will catch the AttributeError as well as the TypeError instead of only catching the later

authored by Asham · committed by Markus Unterwaditzer · parent 42905cc · Browse files · 1 file+1 added−1 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+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:click/_termui_impl.py+1 added-1 removed
29 unmodified lines
30def _length_hint(obj):31 """Returns the length hint of an object."""32 try:33 return len(obj)34 except TypeError:34 except (AttributeError, TypeError):35 try:36 get_hint = type(obj).__length_hint__37 except AttributeError:38 return None
509 unmodified lines