of attributes.
- scoped blocks not properly treat toplevel assignments and imports.
Previously an import suddenly "disappeared" in a scoped block.
+- automatically detect newer Python interpreter versions before loading code
+ from bytecode caches to prevent segfaults on invalid opcodes. The segfault
+ in earlier Jinja2 versions here was not a Jinja2 bug but a limitation in
+ the underlying Python interpreter. If you notice Jinja2 segfaulting in
+ earlier versions after an upgrade of the Python interpreter you don't have
+ to upgrade, it's enough to flush the bytecode cache. This just no longer
+ makes this necessary, Jinja2 will automatically detect these cases now.
Version 2.5.5
-------------
:license: BSD.
"""
from os import path, listdir
+import sys
import marshal
import tempfile
import cPickle as pickle
from jinja2.utils import open_if_exists
-bc_version = 1
-bc_magic = 'j2'.encode('ascii') + pickle.dumps(bc_version, 2)
+bc_version = 2
+
+# magic version used to only change with new jinja versions. With 2.6
+# we change this to also take Python version changes into account. The
+# reason for this is that Python tends to segfault if fed earlier bytecode
+# versions because someone thought it would be a good idea to reuse opcodes
+# or make Python incompatible with earlier versions.
+bc_magic = 'j2'.encode('ascii') + \
+ pickle.dumps(bc_version, 2) + \
+ pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1])
class Bucket(object):