mirror of
https://github.com/python/cpython.git
synced 2025-12-07 09:47:28 +00:00
Patch #525870: Avoid duplicate stat calls, use st_ attributes.
This commit is contained in:
parent
7e30548285
commit
9d3eba87d6
1 changed files with 2 additions and 4 deletions
|
|
@ -102,7 +102,6 @@ import ftplib
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import stat
|
|
||||||
import gopherlib
|
import gopherlib
|
||||||
import posixpath
|
import posixpath
|
||||||
|
|
||||||
|
|
@ -877,10 +876,9 @@ class FileHandler(BaseHandler):
|
||||||
file = req.get_selector()
|
file = req.get_selector()
|
||||||
localfile = url2pathname(file)
|
localfile = url2pathname(file)
|
||||||
stats = os.stat(localfile)
|
stats = os.stat(localfile)
|
||||||
size = stats[stat.ST_SIZE]
|
size = stats.st_size
|
||||||
modified = rfc822.formatdate(stats[stat.ST_MTIME])
|
modified = rfc822.formatdate(stats.st_mtime)
|
||||||
mtype = mimetypes.guess_type(file)[0]
|
mtype = mimetypes.guess_type(file)[0]
|
||||||
stats = os.stat(localfile)
|
|
||||||
headers = mimetools.Message(StringIO(
|
headers = mimetools.Message(StringIO(
|
||||||
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
|
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
|
||||||
(mtype or 'text/plain', size, modified)))
|
(mtype or 'text/plain', size, modified)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue