KeyError in describe_location on user movement
See original GitHub issueHey Brandon–
I hate to open an issue on code that hasn’t been touched for two years, but I was playing python-adventure
today (I recently watched your python/unix keynote and was so happy you ported adventure to python) and hit a bug.
I was going to try to do some debugging myself but I saw a few too many spoilers in the source code.
The exception didn’t crash the game but it did occasionally reoccur. I tried rerunning python-adventure with the same sequence of commands a few times but didn’t see the error again. I believe the error has to do with the random dwarf movements.
I’ve attached the markdown snippet of the first error traceback. I also have a gist of the complete game session as well as a filtered version with just my python commands.
This obviously isn’t very important, but I thought you may want to give it a look!
>>> down
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/personal/python-adventure/adventure/prompt.py", line 18, in __repr__
output = self.game.do_command(self.words)
File "~/personal/python-adventure/adventure/game.py", line 437, in do_command
self._do_command(words)
File "~/personal/python-adventure/adventure/game.py", line 506, in _do_command
self.dispatch_command(words)
File "~/personal/python-adventure/adventure/game.py", line 553, in dispatch_command
return self.do_motion(word1)
File "~/personal/python-adventure/adventure/game.py", line 701, in do_motion
self.move_to(move.action)
File "~/personal/python-adventure/adventure/game.py", line 186, in move_to
self.move_dwarves()
File "~/personal/python-adventure/adventure/game.py", line 325, in move_dwarves
self.describe_location()
File "~/personal/python-adventure/adventure/game.py", line 379, in describe_location
self.write(obj.messages[prop])
KeyError: 0
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
It never would have occurred to me to try picking up a dwarf — thanks for uncovering this, and thanks for writing up your investigation in such detail! I look forward to seeing your pull request, if you find the time to get one written!
I merged your PR (thanks!), and then made two improvements.
First, not needing more than one dwarf in the room, I simplified the test to do
And second, I tracked down the root problem. No objects were getting marked as
is_fixed
because of a bug in the import routine! So the check:was never triggering because objects were marked as being impossible to pick up.
Let me know if the issue now looks resolved from your end, and thanks again for letting me know about it!