throw KeyFormatError when given a code with spaces

This commit is contained in:
Brian Warner 2017-03-07 12:09:25 +01:00
parent aebee61816
commit e518f2b799

View File

@ -17,7 +17,7 @@ from ._rendezvous import RendezvousConnector
from ._lister import Lister
from ._code import Code
from ._terminator import Terminator
from .errors import ServerError, LonelyError, WrongPasswordError
from .errors import ServerError, LonelyError, WrongPasswordError, KeyFormatError
from .util import bytes_to_dict
@attrs
@ -116,6 +116,8 @@ class Boss(object):
def allocate_code(self, code_length):
self._C.allocate_code(code_length)
def set_code(self, code):
if ' ' in code:
raise KeyFormatError("code (%s) contains spaces." % code)
self._C.set_code(code)
@m.input()