From c6d864cf8975415bd4ffee17f29e37f95969c8c9 Mon Sep 17 00:00:00 2001 From: David Lord Date: Sun, 26 Jan 2020 22:22:11 -0800 Subject: [PATCH] increment bytecode cache version --- src/jinja2/bccache.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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) ) -- 2.47.2