diff options
author | David Lord <davidism@gmail.com> | 2020-01-26 22:22:11 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-01-26 22:22:11 -0800 |
commit | c6d864cf8975415bd4ffee17f29e37f95969c8c9 (patch) | |
tree | 6c2d4468e4ad362ad0f8b7a4574aa7848a62a980 /src/jinja2/bccache.py | |
parent | c775bb99497b0c89746c3cc658ace45f9016a12e (diff) | |
download | jinja-c6d864cf8975415bd4ffee17f29e37f95969c8c9.tar.gz |
increment bytecode cache version
Diffstat (limited to 'src/jinja2/bccache.py')
-rw-r--r-- | src/jinja2/bccache.py | 15 |
1 files 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) ) |