summaryrefslogtreecommitdiff
path: root/requests/utils.py
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2016-03-07 08:31:23 +0000
committerCory Benfield <lukasaoz@gmail.com>2016-03-07 08:31:23 +0000
commite034dd1140cb6b6862d5ebc633ba94d332fc2bb2 (patch)
tree7c9788202d346736537e36d87dfd51f5f0de4f28 /requests/utils.py
parent4f378b0e1a2f5f60e2e57daaec80081483f7150e (diff)
downloadpython-requests-e034dd1140cb6b6862d5ebc633ba94d332fc2bb2.tar.gz
Allow for exceptions from tell()
Diffstat (limited to 'requests/utils.py')
-rw-r--r--requests/utils.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/requests/utils.py b/requests/utils.py
index c5c3fd01..c9746d64 100644
--- a/requests/utils.py
+++ b/requests/utils.py
@@ -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)