Skip to content
Myr

Switch to treat files without tell() as zero-length

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Cory Benfield · committed by Cory Benfield · parent e034dd1 · Browse files · 2 files+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−3 removed

  • tests:+1 added−1 removed
  • other:+4 added−2 removed

2 files+5 added−3 removed

modified:requests/utils.py+4 added-2 removed
85 unmodified lines
86 try:87 current_position = o.tell()88 except (OSError, IOError):89 # This can happen in some weird situations, such as when the file90 # is actually a special file descriptor like stdin.91 current_position = 090 # is actually a special file descriptor like stdin. In this91 # instance, we don't know what the length is, so set it to zero and92 # let requests chunk it instead.93 current_position = total_length9495 return max(0, total_length - current_position)9697
631 unmodified lines
modified:tests/test_utils.py+1 added-1 removed
42 unmodified lines
4344 def tell(self):45 raise error()4647 assert super_len(BoomFile()) == 547 assert super_len(BoomFile()) == 0484950class TestGetEnvironProxies:51 """Ensures that IP addresses are correctly matches with ranges
193 unmodified lines