]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fixed issue when slicing static_url version string when none exists.
authorBirk Nilson <me@birknilson.se>
Fri, 2 Dec 2011 14:25:45 +0000 (14:25 +0000)
committerBirk Nilson <me@birknilson.se>
Fri, 2 Dec 2011 14:25:45 +0000 (14:25 +0000)
tornado/web.py

index 906b01284585277172861bdad99bb96ca38dff65..d6a82d5640c46143743b476bcfbf64aefc1851b0 100644 (file)
@@ -1542,7 +1542,6 @@ class StaticFileHandler(RequestHandler):
         ``settings`` is the `Application.settings` dictionary and ```path``
         is the relative location of the requested asset on the filesystem.
         """
-        hsh = None
         abs_path = os.path.join(settings["static_path"], path)
         with cls._lock:
             hashes = cls._static_hashes
@@ -1554,8 +1553,10 @@ class StaticFileHandler(RequestHandler):
                 except Exception:
                     logging.error("Could not open static file %r", path)
                     hashes[abs_path] = None
-            hsh = hashes.get(abs_path)[:5]
-        return hsh
+            hsh = hashes.get(abs_path)
+            if hsh:
+                return hsh[:5]
+        return None
 
 
 class FallbackHandler(RequestHandler):