From: David Lord Date: Mon, 27 Jan 2020 06:22:11 +0000 (-0800) Subject: increment bytecode cache version X-Git-Tag: 2.11.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6d864cf8975415bd4ffee17f29e37f95969c8c9;p=thirdparty%2Fjinja.git increment bytecode cache version --- diff --git a/src/jinja2/bccache.py b/src/jinja2/bccache.py index 6f897451..9c066103 100644 --- a/src/jinja2/bccache.py +++ b/src/jinja2/bccache.py @@ -23,17 +23,14 @@ from ._compat import pickle from ._compat import text_type from .utils import open_if_exists -bc_version = 3 - -# 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_version = 4 +# Magic bytes to identify Jinja bytecode cache files. Contains the +# Python major and minor version to avoid loading incompatible bytecode +# if a project upgrades its Python version. bc_magic = ( - "j2".encode("ascii") + b"j2" + pickle.dumps(bc_version, 2) - + pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1]) + + pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1], 2) )