diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-03-18 08:37:19 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-03-18 08:37:19 (GMT) |
commit | 9d3eba87d697231dde1672bdd30d5f59890700b4 (patch) | |
tree | 85b3d24f745d7c19c6b61c476a3b60c19d9579db /Lib | |
parent | 7e30548285226802702dcdf81c267ebeb00ce2a5 (diff) | |
download | cpython-9d3eba87d697231dde1672bdd30d5f59890700b4.zip cpython-9d3eba87d697231dde1672bdd30d5f59890700b4.tar.gz cpython-9d3eba87d697231dde1672bdd30d5f59890700b4.tar.bz2 |
Patch #525870: Avoid duplicate stat calls, use st_ attributes.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/urllib2.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 512d90c..3c2c104 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -102,7 +102,6 @@ import ftplib import sys import time import os -import stat import gopherlib import posixpath @@ -877,10 +876,9 @@ class FileHandler(BaseHandler): file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) - size = stats[stat.ST_SIZE] - modified = rfc822.formatdate(stats[stat.ST_MTIME]) + size = stats.st_size + modified = rfc822.formatdate(stats.st_mtime) mtype = mimetypes.guess_type(file)[0] - stats = os.stat(localfile) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) |