[New-bugs-announce] [issue31669] string.Template: cods, docs and PEP all disagree on definition of identifier

Thomas Jollans report at bugs.python.org
Tue Oct 3 02:02:28 EDT 2017


New submission from Thomas Jollans <tjol at tjol.eu>:

string.Template matches a $identifier with the regex [_a-z][_a-z0-9]* and re.IGNORECASE. This matches S, ſ and s, but not ß. https://github.com/python/cpython/blob/master/Lib/string.py#L78 (this code came up on python-dev)

The docs specify "any case-insensitive ASCII alphanumeric string (including underscores) that starts with an underscore or ASCII letter.". This includes S and s, but neither ſ nor ß. https://docs.python.org/3/library/string.html#template-strings

The docs refer to PEP 292, which specifies "By default, 'identifier' must spell a Python identifier [...]" This includes S, ſ, s and ß. https://www.python.org/dev/peps/pep-0292/

It's not entirely clear what the correct behaviour is (probably accepting any Python identifier). In any case, the current behaviour of string.Template is a bit silly, but changing it might break stuff.

----------
components: Library (Lib)
messages: 303577
nosy: tjollans
priority: normal
severity: normal
status: open
title: string.Template: cods, docs and PEP all disagree on definition of identifier
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31669>
_______________________________________


More information about the New-bugs-announce mailing list