diff --git a/s3fs/core.py b/s3fs/core.py index 5d0247f4..d41af1ad 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -1981,7 +1981,7 @@ def modified(self, path, version_id=None, refresh=False): if "LastModified" not in info: # This path is a bucket or folder, which do not currently have a modified date raise IsADirectoryError - return info["LastModified"].replace(tzinfo=None) + return info["LastModified"] def sign(self, path, expiration=100, **kwargs): return self.url(path, expires=expiration, **kwargs) diff --git a/s3fs/tests/test_s3fs.py b/s3fs/tests/test_s3fs.py index b243ff1f..cfb572da 100644 --- a/s3fs/tests/test_s3fs.py +++ b/s3fs/tests/test_s3fs.py @@ -2033,6 +2033,7 @@ def test_modified(s3): s3.touch(file_path) modified = s3.modified(path=file_path) assert isinstance(modified, datetime.datetime) + assert modified.tzinfo is not None # Test directory with pytest.raises(IsADirectoryError):