You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Progress bar crashes while trying to get a length hint of a file that is opened using codecs.open function.
Python version: 2.7.11 (64bit) on Windows
Output:
raceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python27\lib\site-packages\click\termui.py", line 306, in progressbar
width=width, color=color)
File "C:\Program Files\Python27\lib\site-packages\click\_termui_impl.py", line 73, in __init__
length = _length_hint(iterable)
File "C:\Program Files\Python27\lib\site-packages\click\_termui_impl.py", line 33, in _length_hint
return len(obj)
File "C:\Program Files\Python27\lib\codecs.py", line 728, in __getattr__
return getattr(self.stream, name)
AttributeError: 'file' object has no attribute '__len__'
The same code works as expected when not using encoding parameter, mainly because codecs.open return the basic open() method result if no encoding is specified.
The _length_hint function catches the TypeError exception but this one produces an AttributeError exception, should be modified to include the AttributeError type as well.
The text was updated successfully, but these errors were encountered:
Progress bar crashes while trying to get a length hint of a file that is opened using codecs.open function.
Python version: 2.7.11 (64bit) on Windows
Output:
To reproduce:
The same code works as expected when not using
encoding
parameter, mainly because codecs.open return the basicopen()
method result if no encoding is specified.The
_length_hint
function catches theTypeError
exception but this one produces anAttributeError
exception, should be modified to include theAttributeError
type as well.The text was updated successfully, but these errors were encountered: