misc: use keyword.kwlist to get list of reserved keywords (#76195)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
097969e58c
commit
ad54651415
|
@ -24,6 +24,7 @@ import html
|
|||
import io
|
||||
import itertools
|
||||
import json
|
||||
import keyword
|
||||
import mimetypes
|
||||
import os
|
||||
import random
|
||||
|
@ -1692,47 +1693,8 @@ class VarnameWidget(ValidatedStringWidget):
|
|||
# "native" id/text keys in datasources; forbid "status" to avoid status
|
||||
# filtering being diverted to a form field.
|
||||
# And forbid all reserved Python keywords so varnames can be used in
|
||||
# dotted expressions (form.var.plop). (keyword.kwlist in Python 3.9)
|
||||
if self.value in (
|
||||
'id',
|
||||
'text',
|
||||
'status',
|
||||
'and',
|
||||
'as',
|
||||
'assert',
|
||||
'async',
|
||||
'await',
|
||||
'break',
|
||||
'class',
|
||||
'continue',
|
||||
'def',
|
||||
'del',
|
||||
'elif',
|
||||
'else',
|
||||
'except',
|
||||
'False',
|
||||
'finally',
|
||||
'for',
|
||||
'from',
|
||||
'global',
|
||||
'if',
|
||||
'import',
|
||||
'in',
|
||||
'is',
|
||||
'lambda',
|
||||
'None',
|
||||
'nonlocal',
|
||||
'not',
|
||||
'or',
|
||||
'pass',
|
||||
'raise',
|
||||
'return',
|
||||
'True',
|
||||
'try',
|
||||
'while',
|
||||
'with',
|
||||
'yield',
|
||||
):
|
||||
# dotted expressions (form.var.plop).
|
||||
if self.value in ('id', 'text', 'status') + tuple(keyword.kwlist):
|
||||
self.error = _('this value is reserved for internal use.')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue