mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Python 2 compatibility
This commit is contained in:
committed by
Nate Prewitt
parent
af7729f64a
commit
d4965a4ec6
+7
-1
@@ -89,8 +89,14 @@ def super_len(o):
|
||||
# StringIO has a notimplemented fileno
|
||||
# BytesIO has seek and not fileno
|
||||
total_length = o.seek(0, 2)
|
||||
# StringIO objects in py2 returns None
|
||||
if total_length is None and hasattr(o, 'tell'):
|
||||
total_length = o.tell()
|
||||
elif total_length is None:
|
||||
total_length = 0
|
||||
|
||||
# seek back to current position to support partially read file-like
|
||||
o.seek(current_position)
|
||||
o.seek(current_position or 0)
|
||||
|
||||
return max(0, total_length - current_position)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user