validate name in symlinkoption

This commit is contained in:
2019-02-11 20:28:03 +01:00
parent 688525f98e
commit c4bb4f90a1
3 changed files with 12 additions and 8 deletions

View File

@ -299,7 +299,7 @@ class Base:
_setattr(self, '_extra', tuple([tuple(extra.keys()), tuple(extra.values())]))
def impl_is_readonly(self) -> str:
# _path is None when initialise SymlinkOption
# _path is None when initialise SymLinkOption
return hasattr(self, '_path') and self._path is not None
def impl_getproperties(self) -> FrozenSet[str]:

View File

@ -19,7 +19,7 @@
# the whole pypy projet is under MIT licence
# ____________________________________________________________
from typing import Any
from .baseoption import BaseOption
from .baseoption import BaseOption, valid_name
from ..i18n import _
@ -29,6 +29,8 @@ class SymLinkOption(BaseOption):
def __init__(self,
name: str,
opt: BaseOption) -> None:
if not valid_name(name):
raise ValueError(_('"{0}" is an invalid name for an option').format(name))
if not isinstance(opt, BaseOption) or \
opt.impl_is_optiondescription() or \
opt.impl_is_symlinkoption():