Skip to content
Myr

Merge pull request #1096 from pallets/compile-encoding

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

compile writes utf8

authored by David Lord · committed by GitHub · parents 8488090, 1db7d51 · Browse files · 2 files+9 added−7 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+9 added−7 removed

  • other:+9 added−7 removed

2 files+9 added−7 removed

modified:jinja2/environment.py+7 added-7 removed
682 unmodified lines
683 # Python 3.3 added a source filesize to the header684 if sys.version_info >= (3, 3):685 py_header += u'\x00\x00\x00\x00'.encode('iso-8859-15')686687 def write_file(filename, data, mode):687 def write_file(filename, data):688 if zip:689 info = ZipInfo(filename)690 info.external_attr = 0o755 << 16691 zip_file.writestr(info, data)692 else:693 f = open(os.path.join(target, filename), mode)694 try:693 if isinstance(data, text_type):694 data = data.encode("utf8")695696 with open(os.path.join(target, filename), "wb") as f:697 f.write(data)696 finally:697 f.close()698699 if zip is not None:700 from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED, ZIP_STORED701 zip_file = ZipFile(target, 'w', dict(deflated=ZIP_DEFLATED,
19 unmodified lines
721722 if py_compile:723 c = self._compile(code, encode_filename(filename))724 write_file(filename + 'c', py_header +725 marshal.dumps(c), 'wb')725 marshal.dumps(c))726 log_function('Byte-compiled "%s" as %s' %727 (name, filename + 'c'))728 else:729 write_file(filename, code, 'w')729 write_file(filename, code)730 log_function('Compiled "%s" as %s' % (name, filename))731 finally:732 if zip:733 zip_file.close()
552 unmodified lines
modified:CHANGES.rst+2 added
58 unmodified lines
59 :class:`~nativetypes.NativeEnvironment` instead of a default60 :class:`Environment`. :issue:`1091`61- After calling ``LRUCache.copy()``, the copy's queue methods point to62 the correct queue. :issue:`843`63- Compiling templates always writes UTF-8 instead of defaulting to the64 system encoding. :issue:`889`656667Version 2.10.368--------------
629 unmodified lines