Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f85278

Browse files
Merge pull request googleapis#141 from e00E/master
Fix file stream recognition for Python 3.
2 parents 374a0d0 + fafe858 commit 7f85278

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

googleapiclient/http.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,7 @@ def next_chunk(self, http=None, num_retries=0):
827827
# The upload was complete.
828828
return (status, body)
829829

830-
# The httplib.request method can take streams for the body parameter, but
831-
# only in Python 2.6 or later. If a stream is available under those
832-
# conditions then use it as the body argument.
833-
if self.resumable.has_stream() and sys.version_info[1] >= 6:
830+
if self.resumable.has_stream():
834831
data = self.resumable.stream()
835832
if self.resumable.chunksize() == -1:
836833
data.seek(self.resumable_progress)

tests/test_discovery.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,22 +1098,6 @@ def stream(self):
10981098
upload = IoBaseHasStream()
10991099

11001100
orig_version = sys.version_info
1101-
sys.version_info = (2, 5, 5, 'final', 0)
1102-
1103-
request = zoo.animals().insert(media_body=upload, body=None)
1104-
1105-
http = HttpMockSequence([
1106-
({'status': '200',
1107-
'location': 'http://upload.example.com'}, ''),
1108-
({'status': '200'}, 'echo_request_headers_as_json'),
1109-
])
1110-
1111-
# This should not raise an exception because stream() shouldn't be called.
1112-
status, body = request.next_chunk(http=http)
1113-
self.assertEqual(body, {
1114-
'Content-Range': 'bytes 0-9/*',
1115-
'Content-Length': '10'
1116-
})
11171101

11181102
sys.version_info = (2, 6, 5, 'final', 0)
11191103

0 commit comments

Comments
 (0)