diff options
author | Federico Caselli <cfederico87@gmail.com> | 2021-09-13 23:09:06 +0200 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2021-10-23 11:11:48 +0200 |
commit | a1d70afb5974125a1a65f590418c7c371bbdb3e6 (patch) | |
tree | 0f4d4ef4170e963aa6784a222e192d16ba753e21 /doc | |
parent | 09cf4f68a7f7f63c2f249d61d7cc6600afe12c1a (diff) | |
download | mako-a1d70afb5974125a1a65f590418c7c371bbdb3e6.tar.gz |
Modernize codeworkflow_test_initial_1_2
- remove python 2 support
- add github workflows
- remove disable unicode
- cleanup compat file
- modernize setup
- use pep517
Change-Id: Ic38dbf478046cec5d0815b468f0c235b4ea5e20c
Diffstat (limited to 'doc')
-rw-r--r-- | doc/build/filtering.rst | 4 | ||||
-rw-r--r-- | doc/build/unicode.rst | 90 | ||||
-rw-r--r-- | doc/build/unreleased/disable_unicode.rst | 4 | ||||
-rw-r--r-- | doc/build/unreleased/py2.rst | 4 |
4 files changed, 11 insertions, 91 deletions
diff --git a/doc/build/filtering.rst b/doc/build/filtering.rst index 984d21c..3d0225e 100644 --- a/doc/build/filtering.rst +++ b/doc/build/filtering.rst @@ -101,9 +101,7 @@ In addition to the ``expression_filter`` argument, the :class:`.TemplateLookup` can specify filtering for all expression tags at the programmatic level. This array-based argument, when given its default argument of ``None``, will be internally set to -``["unicode"]`` (or ``["str"]`` on Python 3), except when -``disable_unicode=True`` is set in which case it defaults to -``["str"]``: +``["unicode"]`` (or ``["str"]`` on Python 3): .. sourcecode:: python diff --git a/doc/build/unicode.rst b/doc/build/unicode.rst index 2f77f6a..c48fce8 100644 --- a/doc/build/unicode.rst +++ b/doc/build/unicode.rst @@ -62,16 +62,7 @@ the storage format for strings. The "pass through encoded data" scheme is what template languages like Cheetah and earlier versions of Myghty do by -default. Mako as of version 0.2 also supports this mode of -operation when using Python 2, using the ``disable_unicode=True`` -flag. However, when using Mako in its default mode of -unicode-aware, it requires explicitness when dealing with -non-ASCII encodings. Additionally, if you ever need to handle -unicode strings and other kinds of encoding conversions more -intelligently, the usage of raw byte-strings quickly becomes a -nightmare, since you are sending the Python interpreter -collections of bytes for which it can make no intelligent -decisions with regards to encoding. In Python 3 Mako only allows +default. In Python 3 Mako only allows usage of native, unicode strings. In normal Mako operation, all parsed template constructs and @@ -255,82 +246,5 @@ which cannot handle encoding of non-ASCII ``unicode`` objects buffering. Otherwise, a custom Mako class called ``FastEncodingBuffer`` is used, which essentially is a super dumbed-down version of ``StringIO`` that gathers all strings into -a list and uses ``u''.join(elements)`` to produce the final output +a list and uses ``''.join(elements)`` to produce the final output -- it's markedly faster than ``StringIO``. - -.. _unicode_disabled: - -Saying to Heck with It: Disabling the Usage of Unicode Entirely -=============================================================== - -Some segments of Mako's userbase choose to make no usage of -Unicode whatsoever, and instead would prefer the "pass through" -approach; all string expressions in their templates return -encoded byte-strings, and they would like these strings to pass -right through. The only advantage to this approach is that -templates need not use ``u""`` for literal strings; there's an -arguable speed improvement as well since raw byte-strings -generally perform slightly faster than unicode objects in -Python. For these users, assuming they're sticking with Python -2, they can hit the ``disable_unicode=True`` flag as so: - -.. sourcecode:: python - - # -*- coding:utf-8 -*- - from mako.template import Template - - t = Template("drôle de petite voix m’a réveillé.", disable_unicode=True, input_encoding='utf-8') - print(t.code) - -The ``disable_unicode`` mode is strictly a Python 2 thing. It is -not supported at all in Python 3. - -The generated module source code will contain elements like -these: - -.. sourcecode:: python - - # -*- coding:utf-8 -*- - # ...more generated code ... - - def render_body(context,**pageargs): - context.caller_stack.push_frame() - try: - __M_locals = dict(pageargs=pageargs) - # SOURCE LINE 1 - context.write('dr\xc3\xb4le de petite voix m\xe2\x80\x99a r\xc3\xa9veill\xc3\xa9.') - return '' - finally: - context.caller_stack.pop_frame() - -Where above that the string literal used within :meth:`.Context.write` -is a regular byte-string. - -When ``disable_unicode=True`` is turned on, the ``default_filters`` -argument which normally defaults to ``["unicode"]`` now defaults -to ``["str"]`` instead. Setting ``default_filters`` to the empty list -``[]`` can remove the overhead of the ``str`` call. Also, in this -mode you **cannot** safely call :meth:`~.Template.render_unicode` -- you'll get -unicode/decode errors. - -The ``h`` filter (HTML escape) uses a less performant pure Python -escape function in non-unicode mode. This because -MarkupSafe only supports Python unicode objects for non-ASCII -strings. - -.. versionchanged:: 0.3.4 - In prior versions, it used ``cgi.escape()``, which has been replaced - with a function that also escapes single quotes. - -Rules for using ``disable_unicode=True`` ----------------------------------------- - -* Don't use this mode unless you really, really want to and you - absolutely understand what you're doing. -* Don't use this option just because you don't want to learn to - use Unicode properly; we aren't supporting user issues in this - mode of operation. We will however offer generous help for the - vast majority of users who stick to the Unicode program. -* Python 3 is unicode by default, and the flag is not available - when running on Python 3. - diff --git a/doc/build/unreleased/disable_unicode.rst b/doc/build/unreleased/disable_unicode.rst new file mode 100644 index 0000000..e15ca79 --- /dev/null +++ b/doc/build/unreleased/disable_unicode.rst @@ -0,0 +1,4 @@ +.. change:: + :tags: py3k + + Removed ``disable_unicode`` flag, that's no longer used in Python 3. diff --git a/doc/build/unreleased/py2.rst b/doc/build/unreleased/py2.rst new file mode 100644 index 0000000..c3e7f8d --- /dev/null +++ b/doc/build/unreleased/py2.rst @@ -0,0 +1,4 @@ +.. change:: + :tags: py3k + + Remove support for Python 2. Mako now requires Python >= 3.6 |