Repository: aws/aws-cli

Issue:
Support Python 3.6
Python 3.6 got released, and some distro (like Fedora) are swithcing to it.


Discussion:

Resolving patch:
diff --git a/awscli/customizations/s3/utils.py b/awscli/customizations/s3/utils.py
--- a/awscli/customizations/s3/utils.py
+++ b/awscli/customizations/s3/utils.py
@@ -216,13 +216,13 @@ def get_file_stat(path):
 
     try:
         update_time = datetime.fromtimestamp(stats.st_mtime, tzlocal())
-    except (ValueError, OSError):
+    except (ValueError, OSError, OverflowError):
         # Python's fromtimestamp raises value errors when the timestamp is out
         # of range of the platform's C localtime() function. This can cause
-        # issues when syncing from systems with a wide range of valid timestamps
-        # to systems with a lower range. Some systems support 64-bit timestamps,
-        # for instance, while others only support 32-bit. We don't want to fail
-        # in these cases, so instead we pass along none.
+        # issues when syncing from systems with a wide range of valid
+        # timestamps to systems with a lower range. Some systems support
+        # 64-bit timestamps, for instance, while others only support 32-bit.
+        # We don't want to fail in these cases, so instead we pass along none.
         update_time = None
 
     return stats.st_size, update_time
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -54,6 +54,7 @@
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
     ),
 )
 


Test patch:
diff --git a/tests/unit/customizations/s3/test_utils.py b/tests/unit/customizations/s3/test_utils.py
--- a/tests/unit/customizations/s3/test_utils.py
+++ b/tests/unit/customizations/s3/test_utils.py
@@ -265,30 +265,29 @@ def test_get_file_stat(self):
             self.assertEqual(size, 3)
             self.assertEqual(time.mktime(update_time.timetuple()), epoch_now)
 
-    def test_get_file_stat_error_message(self):
+    def test_error_message(self):
         with mock.patch('os.stat', mock.Mock(side_effect=IOError('msg'))):
             with self.assertRaisesRegexp(ValueError, 'myfilename\.txt'):
                 get_file_stat('myfilename.txt')
 
-    def test_get_file_stat_returns_epoch_on_invalid_timestamp(self):
+    def assert_handles_fromtimestamp_error(self, error):
         patch_attribute = 'awscli.customizations.s3.utils.datetime'
         with mock.patch(patch_attribute) as datetime_mock:
             with temporary_file('w') as temp_file:
                 temp_file.write('foo')
                 temp_file.flush()
-                datetime_mock.fromtimestamp.side_effect = ValueError()
+                datetime_mock.fromtimestamp.side_effect = error
                 size, update_time = get_file_stat(temp_file.name)
                 self.assertIsNone(update_time)
 
-    def test_get_file_stat_returns_epoch_on_invalid_timestamp_os_error(self):
-        patch_attribute = 'awscli.customizations.s3.utils.datetime'
-        with mock.patch(patch_attribute) as datetime_mock:
-            with temporary_file('w') as temp_file:
-                temp_file.write('foo')
-                temp_file.flush()
-                datetime_mock.fromtimestamp.side_effect = OSError()
-                size, update_time = get_file_stat(temp_file.name)
-                self.assertIsNone(update_time)
+    def test_returns_epoch_on_invalid_timestamp(self):
+        self.assert_handles_fromtimestamp_error(ValueError())
+
+    def test_returns_epoch_on_invalid_timestamp_os_error(self):
+        self.assert_handles_fromtimestamp_error(OSError())
+
+    def test_returns_epoch_on_invalid_timestamp_overflow_error(self):
+        self.assert_handles_fromtimestamp_error(OverflowError())
 
 
 class TestSetsFileUtime(unittest.TestCase):