Skip to content

Commit

Permalink
Merge pull request #282 from timhanus/master
Browse files Browse the repository at this point in the history
force a reload of the template if bytecode fails to unmarshall.  issue #...
  • Loading branch information
mitsuhiko committed Jun 6, 2014
2 parents f5a8003 + 23551a5 commit 8a0358e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jinja2/bccache.py
Expand Up @@ -88,7 +88,12 @@ def load_bytecode(self, f):
if self.checksum != checksum:
self.reset()
return
self.code = marshal_load(f)
# if marshal_load fails then we need to reload
try:
self.code = marshal_load(f)
except (EOFError, ValueError, TypeError):
self.reset()
return

def write_bytecode(self, f):
"""Dump the bytecode into the file or file like object passed."""
Expand Down

0 comments on commit 8a0358e

Please sign in to comment.