mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Allow for exceptions from tell()
This commit is contained in:
+6
-1
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user