11-fix-py3-compatible.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. commit 0dc5e5daf52d205285ba09c67743e5b710f4dfc7
  2. merge: 20bf5810595e13f742f8398fc46b2d6db3ab1d97 8966d3e8ae4112abb24ad7e5ea28e43ece66b29c
  3. author: inkoit
  4. date: 2020-01-09T10:29:26+03:00
  5. revision: 6197593
  6. Fix py3 compatibility in boto2
  7. Делаем как здесь: http://python-future.org/compatible_idioms.html#http-module
  8. Чтобы не делать как здесь: https://a.yandex-team.ru/review/1077328/details
  9. REVIEW: 1079152
  10. --- contrib/python/boto/py3/boto/s3/resumable_download_handler.py (20bf5810595e13f742f8398fc46b2d6db3ab1d97)
  11. +++ contrib/python/boto/py3/boto/s3/resumable_download_handler.py (0dc5e5daf52d205285ba09c67743e5b710f4dfc7)
  12. @@ -19,7 +19,7 @@
  13. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  14. # IN THE SOFTWARE.
  15. import errno
  16. -import httplib
  17. +import http.client
  18. import os
  19. import re
  20. import socket
  21. @@ -92,7 +92,7 @@ class ResumableDownloadHandler(object):
  22. MIN_ETAG_LEN = 5
  23. - RETRYABLE_EXCEPTIONS = (httplib.HTTPException, IOError, socket.error,
  24. + RETRYABLE_EXCEPTIONS = (http.client.HTTPException, IOError, socket.error,
  25. socket.gaierror)
  26. def __init__(self, tracker_file_name=None, num_retries=None):
  27. @@ -290,7 +290,7 @@ class ResumableDownloadHandler(object):
  28. if debug >= 1:
  29. print('Caught exception (%s)' % e.__repr__())
  30. if isinstance(e, IOError) and e.errno == errno.EPIPE:
  31. - # Broken pipe error causes httplib to immediately
  32. + # Broken pipe error causes http.client to immediately
  33. # close the socket (http://bugs.python.org/issue5542),
  34. # so we need to close and reopen the key before resuming
  35. # the download.
  36. @@ -341,7 +341,7 @@ class ResumableDownloadHandler(object):
  37. # which we can safely ignore.
  38. try:
  39. key.close()
  40. - except httplib.IncompleteRead:
  41. + except http.client.IncompleteRead:
  42. pass
  43. sleep_time_secs = 2**progress_less_iterations