File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 9
9
unicode_literals ,
10
10
)
11
11
12
- import re
12
+ try :
13
+ # TODO: remove this when we deprecate Python2
14
+ # re.fullmatch is >= Py3.4 only
15
+ from re import fullmatch
16
+ except ImportError :
17
+ # https://stackoverflow.com/questions/30212413/backport-python-3-4s-regular-expression-fullmatch-to-python-2
18
+ import re
19
+
20
+ def fullmatch (regex , string , flags = 0 ):
21
+ """Emulate python-3.4 re.fullmatch().""" # noqa
22
+ return re .match ("(?:" + regex + r")\Z" , string , flags = flags )
23
+
13
24
from random import choice
14
25
15
26
from builtins import object
@@ -801,7 +812,7 @@ def clean_name(self):
801
812
raise forms .ValidationError (
802
813
_ ("Variable name can't contain spaces" ),
803
814
)
804
- elif not re . fullmatch ('[a-zA-Z0-9_]+' , name ):
815
+ elif not fullmatch ('[a-zA-Z0-9_]+' , name ):
805
816
raise forms .ValidationError (
806
817
_ ('Only letters, numbers and underscore are allowed' ),
807
818
)
You can’t perform that action at this time.
0 commit comments