Skip to content

Commit 782c4de

Browse files
committed
Fixed issue when slicing static_url version string when none exists.
1 parent 2468216 commit 782c4de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tornado/web.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,6 @@ def get_version(cls, settings, path):
15421542
``settings`` is the `Application.settings` dictionary and ```path``
15431543
is the relative location of the requested asset on the filesystem.
15441544
"""
1545-
hsh = None
15461545
abs_path = os.path.join(settings["static_path"], path)
15471546
with cls._lock:
15481547
hashes = cls._static_hashes
@@ -1554,8 +1553,10 @@ def get_version(cls, settings, path):
15541553
except Exception:
15551554
logging.error("Could not open static file %r", path)
15561555
hashes[abs_path] = None
1557-
hsh = hashes.get(abs_path)[:5]
1558-
return hsh
1556+
hsh = hashes.get(abs_path)
1557+
if hsh:
1558+
return hsh[:5]
1559+
return None
15591560

15601561

15611562
class FallbackHandler(RequestHandler):

0 commit comments

Comments
 (0)