Skip to content
Myr

No longer segfault on new versions. This fixes #4

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 5f3d661 · Browse files · 2 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−2 removed

  • other:+18 added−2 removed

2 files+18 added−2 removed

modified:jinja2/bccache.py+11 added-2 removed
13 unmodified lines
14 :copyright: (c) 2010 by the Jinja Team.15 :license: BSD.16"""17from os import path, listdir18import sys19import marshal20import tempfile21import cPickle as pickle22import fnmatch
4 unmodified lines
27 from sha import new as sha128from jinja2.utils import open_if_exists293030bc_version = 131bc_magic = 'j2'.encode('ascii') + pickle.dumps(bc_version, 2)31bc_version = 23233# magic version used to only change with new jinja versions. With 2.634# we change this to also take Python version changes into account. The35# reason for this is that Python tends to segfault if fed earlier bytecode36# versions because someone thought it would be a good idea to reuse opcodes37# or make Python incompatible with earlier versions.38bc_magic = 'j2'.encode('ascii') + \39 pickle.dumps(bc_version, 2) + \40 pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1])414243class Bucket(object):44 """Buckets are used to store the bytecode for one template. It's created45 and initialized by the bytecode cache and passed to the loading functions.46
243 unmodified lines
modified:CHANGES+7 added
15 unmodified lines
16- groupby filter now supports dotted notation for grouping by attributes17 of attributes.18- scoped blocks not properly treat toplevel assignments and imports.19 Previously an import suddenly "disappeared" in a scoped block.20- automatically detect newer Python interpreter versions before loading code21 from bytecode caches to prevent segfaults on invalid opcodes. The segfault22 in earlier Jinja2 versions here was not a Jinja2 bug but a limitation in23 the underlying Python interpreter. If you notice Jinja2 segfaulting in24 earlier versions after an upgrade of the Python interpreter you don't have25 to upgrade, it's enough to flush the bytecode cache. This just no longer26 makes this necessary, Jinja2 will automatically detect these cases now.2728Version 2.5.529-------------30(re-release of 2.5.4 with built documentation removed for filesize.
229 unmodified lines