Allow for exceptions from tell()

This commit is contained in:
Cory Benfield
2016-03-07 08:31:23 +00:00
parent 4f378b0e1a
commit e034dd1140
2 changed files with 20 additions and 2 deletions
+6 -1
View File
@@ -83,7 +83,12 @@ def super_len(o):
)
if hasattr(o, 'tell'):
current_position = o.tell()
try:
current_position = o.tell()
except (OSError, IOError):
# This can happen in some weird situations, such as when the file
# is actually a special file descriptor like stdin.
current_position = 0
return max(0, total_length - current_position)