diff --git a/src/cmdhandler.py b/src/cmdhandler.py index 491f46067f..f60da9decc 100755 --- a/src/cmdhandler.py +++ b/src/cmdhandler.py @@ -133,7 +133,9 @@ class Command(object): """ Instantiates the Command object and does some preliminary parsing. """ - self.raw_input = raw_input + # If we get a unicode string with un-recognizable characters, replace + # them instead of throwing errors. + self.raw_input = unicode(raw_input, errors='replace') self.source_object = source_object self.session = session # The work starts here. @@ -441,7 +443,8 @@ def handle(command, ignore_state=False): # Nothing sent in of value, ignore it. raise ExitCommandHandler - state = None #no state by default + # No state by default. + state = None if command.session and not command.session.logged_in: # Not logged in, look through the unlogged-in command table. diff --git a/src/session.py b/src/session.py index f307dc9662..1c40d41008 100755 --- a/src/session.py +++ b/src/session.py @@ -47,6 +47,10 @@ class SessionProtocol(StatefulTelnetProtocol): self.address = self.getClientAddress() self.name = None self.uid = None + # This is merely here to serve as a convenient reference. It is not + # necessarily the most up to date version of the object, so it is NOT + # safe to look at pobject's location or any other attributes from + # the Object model. self.pobject = None self.logged_in = False # The time the user last issued a command. @@ -78,9 +82,12 @@ class SessionProtocol(StatefulTelnetProtocol): Any line return indicates a command for the purpose of a MUD. So we take the user input and pass it to this session's pobject. """ - if self.pobject: + if self.is_loggedin(): # Session is logged in, run through the normal object execution. - self.pobject.execute_cmd(data, session=self) + # Get the most up to date copy of the Object. + pobject = self.get_pobject() + if pobject: + pobject.execute_cmd(data, session=self) else: # Not logged in, manually execute the command. cmdhandler.handle(cmdhandler.Command(None, data, session=self))