[BUG] `$conj` has no fallback handling for unrecognized words
InspectorCaracal opened this issue · comments
Describe the bug
When using the funcparser's $conj
function with an unknown word, it completely fails out the parsing.
To Reproduce
Steps to reproduce the behavior:
- Load up a vanilla game install.
py self.location.msg_contents("$conj(squanch)", from_obj=self)
- The output message to the room is
$conj(squanch)
Expected behavior
If it can't conjugate the word, it should at least return the input. e.g. print squanch
rather than $conj(squanch)
.
Environment, Evennia version, OS etc
Evennia 2.3.0
Windows 10
Additional context
This issue is caused by the underlying verb_tense
method in evennia.utils.verb_conjugation.conjugate
.
>>> from evennia.utils.verb_conjugation.conjugate import verb_actor_stance_components; verb_actor_stance_components("squanch")
File "./venv/Lib/site-packages/evennia/utils/verb_conjugation/conjugate.py", line 378, in verb_actor_stance_components
tense = verb_tense(verb)
File "./venv/Lib/site-packages/evennia/utils/verb_conjugation/conjugate.py", line 260, in verb_tense
data = verb_tenses[infinitive]
KeyError: ''
I believe an appropriate solution here would be to provide a fallback for that tense lookup.
However, it would be worth considering converting this conjugation system to use the inflect
library rather than refactoring or updating this code, as I believe that would be more maintainable and flexible and the library is already a project dependency.
The inflect
library does not handle verb conjugation. There is a reason we needed to create our own lib for this (which is in turn extracted from the much larger NodeBox
library of which we didn't need most things). Fixed the issue now.
Well darn. It can do so many things, I forgot it can't do that. xD Thanks for the fix!