Skip to content
Myr

Fix Python 3 compatibility of BytecodeCache by checking for `if

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

isinstance(filename, text_type)` instead of `if isinstance(filename, unicode)`

authored by Marc Abramowitz · committed by Armin Ronacher · parent 1070785 · Browse files · 1 file+2 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

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:jinja2/bccache.py+2 added-2 removed
19 unmodified lines
20import tempfile21import fnmatch22from hashlib import sha123from jinja2.utils import open_if_exists24from jinja2._compat import BytesIO, pickle, PY224from jinja2._compat import BytesIO, pickle, PY2, text_type252627# marshal works better on 3.x, one hack less required28if not PY2:
130 unmodified lines
159 """Returns the unique hash key for this template name."""160 hash = sha1(name.encode('utf-8'))161 if filename is not None:162 filename = '|' + filename163 if isinstance(filename, unicode):163 if isinstance(filename, text_type):164 filename = filename.encode('utf-8')165 hash.update(filename)166 return hash.hexdigest()167
144 unmodified lines