No longer segfault on new versions. This fixes #4
diff --git a/CHANGES b/CHANGES
index b06192c..7815a6d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,13 @@
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
-------------
diff --git a/jinja2/bccache.py b/jinja2/bccache.py
index 1e2236c..0f7f566 100644
--- a/jinja2/bccache.py
+++ b/jinja2/bccache.py
@@ -15,6 +15,7 @@
:license: BSD.
"""
from os import path, listdir
+import sys
import marshal
import tempfile
import cPickle as pickle
@@ -27,8 +28,16 @@
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):