Skip to content
Myr

remove unnecessary \b from name regex

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 896aed2 · Browse files · 2 files+9 added−11 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−11 removed

  • tests:+4 added−4 removed
  • other:+5 added−7 removed

2 files+9 added−11 removed

modified:jinja2/lexer.py+5 added-7 removed
13 unmodified lines
14 :copyright: (c) 2017 by the Jinja Team.15 :license: BSD, see LICENSE for more details.16"""17import re18import sys1920from operator import itemgetter18from collections import deque19from operator import itemgetter2021from jinja2._compat import implements_iterator, intern, iteritems, text_type22from jinja2.exceptions import TemplateSyntaxError23from jinja2.utils import LRUCache24from jinja2._compat import iteritems, implements_iterator, text_type, intern242625# cache for the lexers. Exists in order to be able to have multiple26# environments with the same lexer27_lexer_cache = LRUCache(50)28
7 unmodified lines
36# to handle unicode identifiers, otherwise the standard ASCII one.37try:38 compile('föö', '<unknown>', 'eval')39except SyntaxError:42 name_re = re.compile(r'\b[a-zA-Z_][a-zA-Z0-9_]*\b')40 name_re = re.compile(r'[a-zA-Z_][a-zA-Z0-9_]*')41 check_ident = False42else:43 # for whatever reason these do not exist in 'some' verisons of44 # python 3 within \w so we just add them. These are45 # 0x1885 MONGOLIAN LETTER ALI GALI BALUDA46 # 0x1886 MONGOLIAN LETTER ALI GALI THREE BALUDA47 # 0x2118 SCRIPT CAPITAL P48 # 0x212e ESTIMATED SYMBOL51 name_re = re.compile(r'\b[\w\u1885\u1886\u2118\u212e]+\b')49 name_re = re.compile(r'[\w\u1885\u1886\u2118\u212e]+')50 check_ident = True5152float_re = re.compile(r'(?<!\.)\d+\.\d+')53newline_re = re.compile(r'(\r\n|\r|\n)')
680 unmodified lines
modified:tests/test_lexnparse.py+4 added-4 removed
131 unmodified lines
132 (u'き', False, True),133 (u'_', True, True),134 (u'1a', False, False),135 # special cases in addition to \w136 ('\u1885', False, True),137 ('\u1886', False, True),138 ('\u2118', False, True),139 ('\u212e', False, True),136 (u'\u1885', False, True),137 (u'\u1886', False, True),138 (u'\u2118', False, True),139 (u'\u212e', False, True),140 ))141 def test_name(self, env, name, valid2, valid3):142 t = u'{{ ' + name + u' }}'143
491 unmodified lines