Skip to content
Myr

remove Python 2 from docs

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

authored by David Lord · committed by David Lord · parent 0c75d48 · Browse files · 15 files+112 added−242 removed
This commit

State

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

Diff stats

15 files+112 added−242 removed

  • other:+112 added−242 removed

15 files+112 added−242 removed

modified:docs/api.rst+27 added-93 removed
58 unmodified lines
59 for security reasons. As such you are encouraged to explicitly60 configure autoescaping now instead of relying on the default.616263Unicode64-------6566Jinja is using Unicode internally which means that you have to pass Unicode67objects to the render function or bytestrings that only consist of ASCII68characters. Additionally newlines are normalized to one end of line69sequence which is per default UNIX style (``\n``).7071Python 2.x supports two ways of representing string objects. One is the72`str` type and the other is the `unicode` type, both of which extend a type73called `basestring`. Unfortunately the default is `str` which should not74be used to store text based information unless only ASCII characters are75used. With Python 2.6 it is possible to make `unicode` the default on a per76module level and with Python 3 it will be the default.7778To explicitly use a Unicode string you have to prefix the string literal79with a `u`: ``u'Hänsel und Gretel sagen Hallo'``. That way Python will80store the string as Unicode by decoding the string with the character81encoding from the current Python module. If no encoding is specified this82defaults to 'ASCII' which means that you can't use any non ASCII identifier.8384To set a better module encoding add the following comment to the first or85second line of the Python module using the Unicode literal::8687 # -*- coding: utf-8 -*-8889We recommend utf-8 as Encoding for Python modules and templates as it's90possible to represent every Unicode character in utf-8 and because it's91backwards compatible to ASCII. For Jinja the default encoding of templates92is assumed to be utf-8.9394It is not possible to use Jinja to process non-Unicode data. The reason95for this is that Jinja uses Unicode already on the language level. For96example Jinja treats the non-breaking space as valid whitespace inside97expressions which requires knowledge of the encoding or operating on an98Unicode string.99100For more details about Unicode in Python have a look at the excellent101`Unicode documentation`_.102103Another important thing is how Jinja is handling string literals in104templates. A naive implementation would be using Unicode strings for105all string literals but it turned out in the past that this is problematic106as some libraries are typechecking against `str` explicitly. For example107`datetime.strftime` does not accept Unicode arguments. To not break it108completely Jinja is returning `str` for strings that fit into ASCII and109for everything else `unicode`:110111>>> m = Template(u"{% set a, b = 'foo', 'föö' %}").module112>>> m.a113'foo'114>>> m.b115u'f\xf6\xf6'116117118.. _Unicode documentation: https://docs.python.org/3/howto/unicode.html11963High Level API64--------------6566The high-level API is the API you will use in the application to load and
176 unmodified lines
243Notes on Identifiers244--------------------245246Jinja uses Python naming rules. Valid identifiers can be any combination304of Unicode characters accepted by Python.247of characters accepted by Python.248249Filters and tests are looked up in separate namespaces and have slightly250modified identifier syntax. Filters and tests may contain dots to group251filters and tests by topic. For example it's perfectly valid to add a309function into the filter dict and call it `to.unicode`. The regular252function into the filter dict and call it `to.str`. The regular253expression for filter and test identifiers is254``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*```.255256
13 unmodified lines
270.. autoclass:: jinja2.Undefined()271272 .. attribute:: _undefined_hint273331 Either `None` or an unicode string with the error message for332 the undefined object.274 Either `None` or a string with the error message for the275 undefined object.276277 .. attribute:: _undefined_obj278279 Either `None` or the owner object that caused the undefined object
29 unmodified lines
309Undefined objects are created by calling :attr:`undefined`.310311.. admonition:: Implementation312370 :class:`Undefined` objects are implemented by overriding the special371 `__underscore__` methods. For example the default :class:`Undefined`372 class implements `__unicode__` in a way that it returns an empty373 string, however `__int__` and others still fail with an exception. To374 allow conversion to int by returning ``0`` you can implement your own::313 :class:`Undefined` is implemented by overriding the special314 ``__underscore__`` methods. For example the default315 :class:`Undefined` class implements ``__str__`` to returns an empty316 string, while ``__int__`` and others fail with an exception. To317 allow conversion to int by returning ``0`` you can implement your318 own subclass.319320 .. code-block:: python321322 class NullUndefined(Undefined):323 def __int__(self):324 return 0325326 def __float__(self):327 return 0.0328382 To disallow a method, just override it and raise383 :attr:`~Undefined._undefined_exception`. Because this is a very common384 idiom in undefined objects there is the helper method385 :meth:`~Undefined._fail_with_undefined_error` that does the error raising386 automatically. Here a class that works like the regular :class:`Undefined`387 but chokes on iteration::329 To disallow a method, override it and raise330 :attr:`~Undefined._undefined_exception`. Because this is very331 common there is the helper method332 :meth:`~Undefined._fail_with_undefined_error` that raises the error333 with the correct information. Here's a class that works like the334 regular :class:`Undefined` but fails on iteration::335336 class NonIterableUndefined(Undefined):390 __iter__ = Undefined._fail_with_undefined_error337 def __iter__(self):338 self._fail_with_undefined_error()339340341The Context342-----------
179 unmodified lines
522Example::523524 env.policies['urlize.rel'] = 'nofollow noopener'525578``compiler.ascii_str``:579 This boolean controls on Python 2 if Jinja should store ASCII only580 literals as bytestring instead of unicode strings. This used to be581 always enabled for Jinja versions below 2.9 and now can be changed.582 Traditionally it was done this way since some APIs in Python 2 failed583 badly for unicode strings (for instance the datetime strftime API).584 Now however sometimes the inverse is true (for instance str.format).585 If this is set to False then all strings are stored as unicode586 internally.587526``truncate.leeway``:527 Configures the leeway default for the `truncate` filter. Leeway as528 introduced in 2.9 but to restore compatibility with older templates529 it can be configured to `0` to get the old behavior back. The default
83 unmodified lines
613.. autoexception:: jinja2.TemplateSyntaxError614615 .. attribute:: message616679 The error message as utf-8 bytestring.617 The error message.618619 .. attribute:: lineno620683 The line number where the error occurred621 The line number where the error occurred.622623 .. attribute:: name624687 The load name for the template as unicode string.625 The load name for the template.626627 .. attribute:: filename628691 The filename that loaded the template as bytestring in the encoding692 of the file system (most likely utf-8 or mbcs on Windows systems).629 The filename that loaded the template in the encoding of the630 file system (most likely utf-8, or mbcs on Windows systems).631694 The reason why the filename and error message are bytestrings and not695 unicode strings is that Python 2.x is not using unicode for exceptions696 and tracebacks as well as the compiler. This will change with Python 3.697632.. autoexception:: jinja2.TemplateRuntimeError633634.. autoexception:: jinja2.TemplateAssertionError635
191 unmodified lines
827 This is the low level render function. It's passed a :class:`Context`828 that has to be created by :meth:`new_context` of the same template or829 a compatible template. This render function is generated by the830 compiler from the template code and returns a generator that yields897 unicode strings.831 strings.832833 If an exception in the template code happens the template engine will834 not rewrite the exception but pass through the original one. As a835 matter of fact this function should only be called from within a
32 unmodified lines
modified:docs/extensions.rst+4 added-6 removed
42 unmodified lines
4344.. method:: jinja2.Environment.install_gettext_translations(translations, newstyle=False)4546 Installs a translation globally for the environment. The47 ``translations`` object must implement ``gettext`` and ``ngettext``48 (or ``ugettext`` and ``ungettext`` for Python 2).47 ``translations`` object must implement ``gettext`` and ``ngettext``.48 :class:`gettext.NullTranslations`, :class:`gettext.GNUTranslations`,49 and `Babel`_\s ``Translations`` are supported.5051 .. versionchanged:: 2.5 Added new-style gettext support.
9 unmodified lines
61.. method:: jinja2.Environment.install_gettext_callables(gettext, ngettext, newstyle=False)6263 Install the given ``gettext`` and ``ngettext`` callables into the64 environment. They should behave exactly like66 :func:`gettext.gettext` and :func:`gettext.ngettext` (or67 ``ugettext`` and ``ungettext`` for Python 2).65 :func:`gettext.gettext` and :func:`gettext.ngettext`.6667 If ``newstyle`` is activated, the callables are wrapped to work like68 newstyle callables. See :ref:`newstyle-gettext` for more information.69
13 unmodified lines
83 - ``lineno`` is the number of the line on which the string was84 found.85 - ``function`` is the name of the ``gettext`` function used (if86 the string was extracted from embedded Python code).89 - ``message`` is the string itself (``unicode`` on Python 2), or a90 tuple of strings for functions with multiple arguments.87 - ``message`` is the string itself, or a tuple of strings for88 functions with multiple arguments.8990 If `Babel`_ is installed, see :ref:`babel-integration` to extract91 the strings.92
310 unmodified lines
modified:docs/faq.rst+10 added-30 removed
123 unmodified lines
124instead that one can assign to a variable by using set::125126 {% set comments = get_latest_comments() %}127128My tracebacks look weird. What's happening?129--------------------------------------------128My tracebacks look weird. What's happening?129-------------------------------------------130131If the debugsupport module is not compiled and you are using a Python132installation without ctypes (Python 2.4 without ctypes, Jython or Google's133AppEngine) Jinja is unable to provide correct debugging information and134the traceback may be incomplete. There is currently no good workaround135for Jython or the AppEngine as ctypes is unavailable there and it's not136possible to use the debugsupport extension.131Jinja can rewrite tracebacks so they show the template lines numbers and132source rather than the underlying compiled code, but this requires133special Python support. CPython <3.7 requires ``ctypes``, and PyPy134requires transparent proxy support.135138If you are working in the Google AppEngine development server you can139whitelist the ctypes module to restore the tracebacks. This however won't140work in production environments::136If you are using Google App Engine, ``ctypes`` is not available. You can137make it available in development, but not in production.138139.. code-block:: python140141 import os142 if os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'):143 from google.appengine.tools.devappserver2.python import sandbox144 sandbox._WHITE_LIST_C_MODULES += ['_ctypes', 'gestalt']145146Credit for this snippet goes to `Thomas Johansson147<https://stackoverflow.com/questions/3086091/debug-jinja2-in-google-app-engine/3694434#3694434>`_148150Why is there no Python 2.3/2.4/2.5/2.6/3.1/3.2/3.3 support?151-----------------------------------------------------------152153Python 2.3 is missing a lot of features that are used heavily in Jinja. This154decision was made as with the upcoming Python 2.6 and 3.0 versions it becomes155harder to maintain the code for older Python versions. If you really need156Python 2.3 support you either have to use Jinja 1 or other templating157engines that still support 2.3.158159Python 2.4/2.5/3.1/3.2 support was removed when we switched to supporting160Python 2 and 3 by the same sourcecode (without using 2to3). It was required to161drop support because only Python 2.6/2.7 and >=3.3 support byte and unicode162literals in a way compatible to each other version. If you really need support163for older Python 2 (or 3) versions, you can just use Jinja 2.6.164165Python 2.6/3.3 support was dropped because it got dropped in various upstream166projects (such as wheel or pytest), which would make it difficult to continue167supporting it. Jinja 2.10 was the last version supporting Python 2.6/3.3.168149My Macros are overridden by something150-------------------------------------151152In some situations the Jinja scoping appears arbitrary:
23 unmodified lines
modified:docs/index.rst+3 added-26 removed
5 unmodified lines
6.. image:: _static/jinja-logo.png7 :align: center8 :target: https://palletsprojects.com/p/jinja/910Jinja is a modern and designer-friendly templating language for Python,11modelled after Django's templates. It is fast, widely used and secure12with the optional sandboxed template execution environment:10Jinja is a fast, expressive, extensible templating engine. Special11placeholders in the template allow writing code similar to Python12syntax. Then the template is passed data to render the final document.1314.. sourcecode:: html+jinja1516 <title>{% block title %}{% endblock %}</title>17 <ul>18 {% for user in users %}19 <li><a href="{{ user.url }}">{{ user.username }}</a></li>20 {% endfor %}21 </ul>2223Features:2425- sandboxed execution26- powerful automatic HTML escaping system for XSS prevention27- template inheritance28- compiles down to the optimal python code just in time29- optional ahead-of-time template compilation30- easy to debug. Line numbers of exceptions directly point to31 the correct line in the template.32- configurable syntax3314.. toctree::15 :maxdepth: 216 :caption: Contents:17
7 unmodified lines
25 switching26 tricks27 faq28 changelog4950* :ref:`genindex`51* :ref:`search`
modified:docs/intro.rst+37 added-56 removed
1Introduction2============34This is the documentation for the Jinja general purpose templating language.5Jinja is a library for Python that is designed to be flexible, fast and secure.4Jinja is a fast, expressive, extensible templating engine. Special5placeholders in the template allow writing code similar to Python6syntax. Then the template is passed data to render the final document.77If you have any exposure to other text-based template languages, such as Smarty or8Django, you should feel right at home with Jinja. It's both designer and9developer friendly by sticking to Python's principles and adding functionality10useful for templating environments.8It includes:912Prerequisites13-------------10- Template inheritance and inclusion.11- Define and import macros within templates.12- HTML templates can use autoescaping to prevent XSS from untrusted13 user input.14- A sandboxed environment can safely render untrusted templates.15- AsyncIO support for generating templates and calling async16 functions.17- I18N support with Babel.18- Templates are compiled to optimized Python code just-in-time and19 cached, or can be compiled ahead-of-time.20- Exceptions point to the correct line in templates to make debugging21 easier.22- Extensible filters, tests, functions, and even syntax.2315Jinja works with Python 2.7.x and >= 3.5. If you are using Python163.2 you can use an older release of Jinja (2.6) as support for Python 3.217was dropped in Jinja version 2.7. The last release which supported Python 2.618and 3.3 was Jinja 2.10.24Jinja's philosophy is that while application logic belongs in Python if25possible, it shouldn't make the template designer's job difficult by26restricting functionality too much.2720If you wish to use the :class:`~jinja2.PackageLoader` class, you will also21need `setuptools`_ or `distribute`_ installed at runtime.2829Installation30------------3126You can install the most recent Jinja version using `pip`_::32We recommend using the latest version of Python. Jinja supports Python333.6 and newer. We also recommend using a `virtual environment`_ in order34to isolate your project dependencies from other projects and the system.3528 pip install Jinja236.. _virtual environment: https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments3730This will install Jinja in your Python installation's site-packages directory.38Install the most recent Jinja version using pip:3932Installing the development version33~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~40.. code-block:: text41351. Install `git`_362. ``git clone git://github.com/pallets/jinja.git``373. ``cd jinja2``384. ``ln -s jinja2 /usr/lib/python2.X/site-packages``42 $ pip install Jinja24340As an alternative to steps 4 you can also do ``python setup.py develop``41which will install the package via `distribute` in development mode. This also42has the advantage that the C extensions are compiled.4444.. _distribute: https://pypi.org/project/distribute/45.. _setuptools: https://pypi.org/project/setuptools/46.. _pip: https://pypi.org/project/pip/47.. _git: https://git-scm.com/45Dependencies46~~~~~~~~~~~~4748These will be installed automatically when installing Jinja.4950MarkupSafe Dependency51~~~~~~~~~~~~~~~~~~~~~50- `MarkupSafe`_ escapes untrusted input when rendering templates to51 avoid injection attacks.5253As of version 2.7 Jinja depends on the `MarkupSafe`_ module. If you install54Jinja via ``pip`` it will be installed automatically for you.5553.. _MarkupSafe: https://markupsafe.palletsprojects.com/5458Basic API Usage59---------------5561This section gives you a brief introduction to the Python API for Jinja62templates.56Optional Dependencies57~~~~~~~~~~~~~~~~~~~~~5864The most basic way to create a template and render it is through65:class:`~jinja2.Template`. This however is not the recommended way to66work with it if your templates are not loaded from strings but the file67system or another data source:59These distributions will not be installed automatically.6069>>> from jinja2 import Template70>>> template = Template('Hello {{ name }}!')71>>> template.render(name='John Doe')72u'Hello John Doe!'61- `Babel`_ provides translation support in templates.6274By creating an instance of :class:`~jinja2.Template` you get back a new template75object that provides a method called :meth:`~jinja2.Template.render` which when76called with a dict or keyword arguments expands the template. The dict77or keywords arguments passed to the template are the so-called "context"78of the template.7980What you can see here is that Jinja is using unicode internally and the81return value is an unicode string. So make sure that your application is82indeed using unicode internally.63.. _Babel: http://babel.pocoo.org/
modified:docs/switching.rst+6 added-6 removed
30 unmodified lines
31 provides a :class:`Template` class that can be used to do the same, but32 with optional additional configuration.3334Automatic unicode conversion35 Jinja 1 performed automatic conversion of bytestrings in a given encoding36 into unicode objects. This conversion is no longer implemented as it37 was inconsistent as most libraries are using the regular Python ASCII38 bytestring to Unicode conversion. An application powered by Jinja 239 *has to* use unicode internally everywhere or make sure that Jinja 2 only40 gets unicode strings passed.35 Jinja 1 performed automatic conversion of bytes in a given encoding36 into unicode objects. This conversion is no longer implemented as it37 was inconsistent as most libraries are using the regular Python38 ASCII bytes to Unicode conversion. An application powered by Jinja 239 *has to* use unicode internally everywhere or make sure that Jinja 240 only gets unicode strings passed.4142i18n43 Jinja 1 used custom translators for internationalization. i18n is now44 available as Jinja 2 extension and uses a simpler, more gettext friendly
182 unmodified lines
modified:docs/templates.rst+2 added-3 removed
600 unmodified lines
601602Jinja functions (macros, `super`, `self.BLOCKNAME`) always return template603data that is marked as safe.604605String literals in templates with automatic escaping are considered unsafe606because native Python strings (``str``, ``unicode``, ``basestring``) are not607`MarkupSafe.Markup` strings with an ``__html__`` attribute.605String literals in templates with automatic escaping are considered606unsafe because native Python strings are not safe.607608.. _list-of-control-structures:609610List of Control Structures
1209 unmodified lines
modified:src/jinja2/bccache.py+1 added-1 removed
282 unmodified lines
283 - `cachelib <https://github.com/pallets/cachelib>`_284 - `python-memcached <https://pypi.org/project/python-memcached/>`_285286 (Unfortunately the django cache interface is not compatible because it287 does not support storing binary data, only unicode. You can however pass287 does not support storing binary data, only text. You can however pass288 the underlying cache client to the bytecode cache which is available289 as `django.core.cache.cache._client`.)290291 The minimal interface for the client passed to the constructor is this:
59 unmodified lines
modified:src/jinja2/environment.py+6 added-6 removed
1079 unmodified lines
10801081 template.render(knights='that say nih')1082 template.render({'knights': 'that say nih'})10831084 This will return the rendered template as unicode string.1084 This will return the rendered template as a string.1085 """1086 vars = dict(*args, **kwargs)1087 try:1088 return concat(self.root_render_func(self.new_context(vars)))
23 unmodified lines
1112 def generate(self, *args, **kwargs):1113 """For very large templates it can be useful to not render the whole1114 template at once but evaluate each statement after another and yield1115 piece for piece. This method basically does exactly that and returns1116 a generator that yields one item after another as unicode strings.1116 a generator that yields one item after another as strings.11171118 It accepts the same arguments as :meth:`render`.1119 """1120 vars = dict(*args, **kwargs)
101 unmodified lines
1222@implements_to_string1223class TemplateModule(object):1224 """Represents an imported template. All the exported names of the1225 template are available as attributes on this object. Additionally1226 converting it into an unicode- or bytestrings renders the contents.1226 converting it into a string renders the contents.1227 """12281229 def __init__(self, template, context, body_stream=None):1230 if body_stream is None:
46 unmodified lines
1277class TemplateStream(object):1278 """A template stream works pretty much like an ordinary python generator1279 but it can buffer multiple items to reduce the number of total iterations.1280 Per default the output is unbuffered which means that for every unbuffered1281 instruction in the template one unicode string is yielded.1281 instruction in the template one string is yielded.12821283 If buffering is enabled with a buffer size of 5, five items are combined1284 into a new unicode string. This is mainly useful if you are streaming1284 into a new string. This is mainly useful if you are streaming1285 big templates to a client via WSGI which flushes after each iteration.1286 """12871288 def __init__(self, gen):
1 unmodified line
1290 self.disable_buffering()12911292 def dump(self, fp, encoding=None, errors="strict"):1293 """Dump the complete stream into a file or file-like object.1294 Per default unicode strings are written, if you want to encode1294 Per default strings are written, if you want to encode1295 before writing specify an `encoding`.12961297 Example usage::1298
64 unmodified lines
modified:src/jinja2/ext.py+2 added-2 removed
536 unmodified lines
537538 * ``lineno`` is the number of the line on which the string was found,539 * ``function`` is the name of the ``gettext`` function used (if the540 string was extracted from embedded Python code), and541 * ``message`` is the string itself (a ``unicode`` object, or a tuple542 of ``unicode`` objects for functions with multiple string arguments).541 * ``message`` is the string, or a tuple of strings for functions542 with multiple string arguments.543544 This extraction function operates on the AST and is because of that unable545 to extract any comments. For comment support you have to use the babel546 extraction interface or extract comments yourself.
158 unmodified lines
modified:src/jinja2/lexer.py+3 added-1 removed
605 unmodified lines
606 ],607 }608609 def _normalize_newlines(self, value):610 """Called for strings and template data to normalize it to unicode."""610 """Replace all newlines with the configured sequence in strings611 and template data.612 """613 return newline_re.sub(self.newline_sequence, value)614615 def tokenize(self, source, name=None, filename=None, state=None):616 """Calls tokeniter + tokenize and wraps it in a token stream."""
227 unmodified lines
modified:src/jinja2/loaders.py+6 added-6 removed
75 unmodified lines
76 tuple in the form ``(source, filename, uptodate)`` or raise a77 `TemplateNotFound` error if it can't locate the template.7879 The source part of the returned tuple must be the source of the80 template as unicode string or a ASCII bytestring. The filename should81 be the name of the file on the filesystem if it was loaded from there,82 otherwise `None`. The filename is used by python for the tracebacks80 template as a string. The filename should be the name of the81 file on the filesystem if it was loaded from there, otherwise82 ``None``. The filename is used by Python for the tracebacks83 if no loader extension is used.8485 The last item in the tuple is the `uptodate` function. If auto86 reloading is enabled it's always called to check if the template
269 unmodified lines
356 return results357358359class DictLoader(BaseLoader):360 """Loads a template from a python dict. It's passed a dict of unicode361 strings bound to template names. This loader is useful for unittesting:360 """Loads a template from a Python dict mapping template names to361 template source. This loader is useful for unittesting:362363 >>> loader = DictLoader({'index.html': 'source here'})364365 Because auto reloading is rarely useful this is disabled per default.
14 unmodified lines
380381class FunctionLoader(BaseLoader):382 """A loader that is passed a function which does the loading. The383 function receives the name of the template and has to return either384 an unicode string with the template source, a tuple in the form ``(source,384 a string with the template source, a tuple in the form ``(source,385 filename, uptodatefunc)`` or `None` if the template does not exist.386387 >>> def load_template(name):388 ... if name == 'index.html':
184 unmodified lines
modified:src/jinja2/nodes.py+2 added-2 removed
786 unmodified lines
787 return slice(const(self.start), const(self.stop), const(self.step))788789790class Concat(Expr):791 """Concatenates the list of expressions provided after converting them to792 unicode.791 """Concatenates the list of expressions provided after converting792 them to strings.793 """794795 fields = ("nodes",)796
292 unmodified lines
modified:src/jinja2/runtime.py+2 added-2 removed
58 unmodified lines
59 return x606162def markup_join(seq):63 """Concatenation that escapes if necessary and converts to unicode."""63 """Concatenation that escapes if necessary and converts to string."""64 buf = []65 iterator = imap(soft_unicode, seq)66 for arg in iterator:67 buf.append(arg)
2 unmodified lines
70 return concat(buf)717273def unicode_join(seq):74 """Simple args to unicode conversion and concatenation."""74 """Simple args to string conversion and concatenation."""75 return concat(imap(text_type, seq))767778def new_context(
933 unmodified lines
modified:src/jinja2/sandbox.py+1 added-2 removed
242 unmodified lines
243 True244 >>> modifies_known_mutable([], "index")245 False246247 If called with an unsupported object (such as unicode) `False` is248 returned.247 If called with an unsupported object, ``False`` is returned.248249 >>> modifies_known_mutable("foo", "upper")250 False251 """
258 unmodified lines