From e034dd1140cb6b6862d5ebc633ba94d332fc2bb2 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Mon, 7 Mar 2016 08:31:23 +0000 Subject: Allow for exceptions from tell() --- requests/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'requests/utils.py') 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) -- cgit v1.2.1