Skip to content

Commit 2e519dd

Browse files
authored
gh-155358: Use named attributes with os module (#155366)
Replace os.stat() result: * st[1] => st.st_ino * st[6] => st.st_size * st[ST_MTIME] => st_mtime: change int type to float
1 parent f8cfa0c commit 2e519dd

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

Lib/http/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def send_head(self):
857857

858858
self.send_response(HTTPStatus.OK)
859859
self.send_header("Content-type", ctype)
860-
self.send_header("Content-Length", str(fs[6]))
860+
self.send_header("Content-Length", str(fs.st_size))
861861
self.send_header("Last-Modified",
862862
self.date_time_string(fs.st_mtime))
863863
self._send_extra_response_headers()

Lib/test/test_os/test_posix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,8 +1823,8 @@ def test_link_dir_fd(self):
18231823
self.skipTest('posix.link(): %s' % e)
18241824
self.addCleanup(posix.unlink, fulllinkname)
18251825
# should have same inodes
1826-
self.assertEqual(posix.stat(fullname)[1],
1827-
posix.stat(fulllinkname)[1])
1826+
self.assertEqual(posix.stat(fullname).st_ino,
1827+
posix.stat(fulllinkname).st_ino)
18281828

18291829
@unittest.skipUnless(os.mkdir in os.supports_dir_fd, "test needs dir_fd support in os.mkdir()")
18301830
def test_mkdir_dir_fd(self):

Tools/c-analyzer/distutils/dep_util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ def newer (source, target):
2020
if not os.path.exists(target):
2121
return 1
2222

23-
from stat import ST_MTIME
24-
mtime1 = os.stat(source)[ST_MTIME]
25-
mtime2 = os.stat(target)[ST_MTIME]
23+
mtime1 = os.stat(source).st_mtime
24+
mtime2 = os.stat(target).st_mtime
2625

2726
return mtime1 > mtime2
2827

0 commit comments

Comments
 (0)