From 1c99e89f1ca70dab5389a7f67af97ec4baa3469e Mon Sep 17 00:00:00 2001 From: Count Infinity Date: Mon, 10 Nov 2025 22:29:19 -0700 Subject: [PATCH 1/2] Fix Unexpected keyword argument 'prototype' error when spawning --- evennia/prototypes/tests.py | 39 +++++++++++++++++++++++++++++++++++++ evennia/utils/funcparser.py | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/evennia/prototypes/tests.py b/evennia/prototypes/tests.py index 4a0b1d1a1b..1422c58d40 100644 --- a/evennia/prototypes/tests.py +++ b/evennia/prototypes/tests.py @@ -1045,6 +1045,45 @@ class TestIssue2908(BaseEvenniaTest): self.assertEqual(obj[0].location, self.room1) +class TestIssue3824(BaseEvenniaTest): + """ + Test that $obj, $objlist, and $search callables work correctly when spawning prototypes. + + """ + + def test_spawn_with_search_callables(self): + """Test spawning prototype with $obj, $objlist, and $search callables.""" + # Setup: tag some objects for searching + self.room1.tags.add("test_location", category="zone") + self.room2.tags.add("test_location", category="zone") + self.obj1.tags.add("test_item", category="item_type") + + # Create prototype using all three search callables + prot = { + "prototype_key": "test_search_callables", + "typeclass": "evennia.objects.objects.DefaultObject", + "key": "test object", + "attr_obj": f"$obj({self.obj1.dbref})", + "attr_search": "$search(Char)", + "attr_objlist": "$objlist(test_location, category=zone, type=tag)", + } + + # This should not raise TypeError about 'prototype' kwarg + objs = spawner.spawn(prot, caller=self.char1) + + self.assertEqual(len(objs), 1) + obj = objs[0] + + # Verify all search callables worked correctly + self.assertEqual(obj.db.attr_obj, self.obj1) + self.assertEqual(obj.db.attr_search, self.char1) + # attr_objlist should be a list or list-like object with 2 rooms + objlist = obj.db.attr_objlist + self.assertEqual(len(objlist), 2) + self.assertIn(self.room1, objlist) + self.assertIn(self.room2, objlist) + + class TestIssue3101(EvenniaCommandTest): """ Spawning and using create_object should store the same `typeclass_path` if using diff --git a/evennia/utils/funcparser.py b/evennia/utils/funcparser.py index 2ed3243004..64aa25c503 100644 --- a/evennia/utils/funcparser.py +++ b/evennia/utils/funcparser.py @@ -1131,12 +1131,12 @@ def funcparser_callable_search(*args, caller=None, access="control", **kwargs): - "$search(beach, category=outdoors, type=tag) """ - # clean out funcparser-specific kwargs so we can use the kwargs for + # clean out funcparser and protfunc_parser-specific kwargs so we can use the kwargs for # searching search_kwargs = { key: value for key, value in kwargs.items() - if key not in ("funcparser", "raise_errors", "type", "return_list") + if key not in ("funcparser", "raise_errors", "type", "return_list", "prototype") } return_list = str(kwargs.pop("return_list", "false")).lower() == "true" From e834e34fd155ceaec733caedb89d2b772b999cce Mon Sep 17 00:00:00 2001 From: Count Infinity Date: Wed, 19 Nov 2025 00:18:31 -0700 Subject: [PATCH 2/2] Add searchable --- evennia/prototypes/tests.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/evennia/prototypes/tests.py b/evennia/prototypes/tests.py index 1422c58d40..362ef8bcf1 100644 --- a/evennia/prototypes/tests.py +++ b/evennia/prototypes/tests.py @@ -1047,18 +1047,19 @@ class TestIssue2908(BaseEvenniaTest): class TestIssue3824(BaseEvenniaTest): """ - Test that $obj, $objlist, and $search callables work correctly when spawning prototypes. + Test that $obj, $objlist, $search, and $dbref callables work correctly when spawning prototypes. + Regression test for bug where 'prototype' kwarg was passed to search functions causing TypeError. """ def test_spawn_with_search_callables(self): - """Test spawning prototype with $obj, $objlist, and $search callables.""" + """Test spawning prototype with $obj, $objlist, $search, and $dbref callables.""" # Setup: tag some objects for searching self.room1.tags.add("test_location", category="zone") self.room2.tags.add("test_location", category="zone") self.obj1.tags.add("test_item", category="item_type") - # Create prototype using all three search callables + # Create prototype using all search callables prot = { "prototype_key": "test_search_callables", "typeclass": "evennia.objects.objects.DefaultObject", @@ -1066,6 +1067,7 @@ class TestIssue3824(BaseEvenniaTest): "attr_obj": f"$obj({self.obj1.dbref})", "attr_search": "$search(Char)", "attr_objlist": "$objlist(test_location, category=zone, type=tag)", + "attr_dbref": f"$dbref({self.obj1.dbref})", } # This should not raise TypeError about 'prototype' kwarg @@ -1077,13 +1079,13 @@ class TestIssue3824(BaseEvenniaTest): # Verify all search callables worked correctly self.assertEqual(obj.db.attr_obj, self.obj1) self.assertEqual(obj.db.attr_search, self.char1) + self.assertEqual(obj.db.attr_dbref, self.obj1) # attr_objlist should be a list or list-like object with 2 rooms objlist = obj.db.attr_objlist self.assertEqual(len(objlist), 2) self.assertIn(self.room1, objlist) self.assertIn(self.room2, objlist) - class TestIssue3101(EvenniaCommandTest): """ Spawning and using create_object should store the same `typeclass_path` if using