diff --git a/s3fs/core.py b/s3fs/core.py index 64fb1443..e9e8d8f8 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -1992,7 +1992,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 173fcef4..d2c12570 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):