internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: evennia/evennia

Issue:
[BUG] Unban Command Msg Display
#### Summary:
Unban Command does not display the final `.msg` due to a syntax error.

#### Reproduce:
Steps to reproduce the behavior:
1. Fresh installation
2. Create a ban.
3. Attempt to unban.
4. See error

#### Expected behavior
Unban should properly display: "Cleared ban `num`: `value`"



Discussion:

Resolving patch:
diff --git a/evennia/commands/default/admin.py b/evennia/commands/default/admin.py
--- a/evennia/commands/default/admin.py
+++ b/evennia/commands/default/admin.py
@@ -271,16 +271,16 @@ def func(self):
         else:
             # all is ok, ask, then clear ban
             ban = banlist[num - 1]
-            value = " ".join([s for s in ban[:2]])
+            value = (" ".join([s for s in ban[:2]])).strip()
 
-            ret = yield(f"Are you sure you want to unban {num}: '{value}' [Y]/N?")
+            ret = yield(f"Are you sure you want to unban {num}: '|w{value}|n' [Y]/N?")
             if str(ret).lower() in ("n", "no"):
                 self.caller.msg("Aborted.")
                 return
 
             del banlist[num - 1]
             ServerConfig.objects.conf("server_bans", banlist)
-            self.caller.msg(f"Cleared ban {num}: '{value}'" % (num, value))
+            self.caller.msg(f"Cleared ban {num}: '{value}'")
             logger.log_sec(
                 "Unbanned: {value.strip()} (Caller: {self.caller}, IP: {self.session.address})."
             )


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] NAttributes are not shown in examine
#### Describe the bug
NAttributes are not displayed under examination.

#### To Reproduce
Steps to reproduce the behavior:
1. Set an NAttribute on anything.
2. Examine it.
4. See lack of NAttribute.

#### Expected behavior
See NAttributes when they exist.

#### Develop-branch commit
Evennia 1.0-dev (rev c2f4f8568) (rev c2f4f8568)

#### Additional context
Examine calls get_formatted_obj_data which calls format_nattributes which tries to run obj.nattributes.all(return_tuples=True) but nattributes is considered an 'AttributeHandler' and you end up with 
```
self.nattributes.all(return_tuples=True)
TypeError: AttributeHandler.all() got an unexpected keyword argument 'return_tuples'
```

It looks to me like NAttributeHandler was removed in branch-develop, and along with it this definition of all():

```
    def all(self, return_tuples=False):
        """
        List the contents of the handler.

        Args:
            return_tuples (bool, optional): Defines if the Nattributes
                are returns as a list of keys or as a list of `(key, value)`.

        Returns:
            nattributes (list): A list of keys `[key, key, ...]` or a
                list of tuples `[(key, value), ...]` depending on the
                setting of `return_tuples`.

        """
        if return_tuples:
            return [(key, value) for (key, value) in self._store.items() if not key.startswith("_")]
        return [key for key in self._store if not key.startswith("_")]
```

https://www.evennia.com/docs/latest/_modules/evennia/server/serversession.html#NAttributeHandler.all


Discussion:

Resolving patch:
diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py
--- a/evennia/commands/default/building.py
+++ b/evennia/commands/default/building.py
@@ -2716,13 +2716,13 @@ def format_attributes(self, obj):
 
     def format_nattributes(self, obj):
         try:
-            ndb_attr = obj.nattributes.all(return_tuples=True)
+            ndb_attr = obj.nattributes.all()
         except Exception:
             return
 
         if ndb_attr and ndb_attr[0]:
             return "\n  " + "  \n".join(
-                sorted(self.format_single_attribute(attr) for attr, value in ndb_attr)
+                sorted(self.format_single_attribute(attr) for attr in ndb_attr)
             )
 
     def format_exits(self, obj):
diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py
--- a/evennia/objects/objects.py
+++ b/evennia/objects/objects.py
@@ -928,7 +928,7 @@ def logerr(string="", err=None):
             try:
                 self.announce_move_from(destination, **kwargs)
             except Exception as err:
-                logerr(errtxt.format(err="at_announce_move()"), err)
+                logerr(errtxt.format(err="announce_move_from()"), err)
                 return False
 
         # Perform move


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] Syntax error in $pron callable
#### Describe the bug
[This line](https://github.com/evennia/evennia/blob/473f2e37932759ab07e2e062ba461569106aef87/evennia/utils/funcparser.py#L1290) is incorrect, causing `$pron` parsing to fail. It should be `callable(caller.gender)`

#### Develop-branch commit
473f2e379



Discussion:

Resolving patch:
diff --git a/evennia/utils/funcparser.py b/evennia/utils/funcparser.py
--- a/evennia/utils/funcparser.py
+++ b/evennia/utils/funcparser.py
@@ -22,7 +22,7 @@ def _helper(x):
     # use underscore to NOT make the function available as a callable
 
 def funcname(*args, **kwargs):
-    # this can be accecssed as $funcname(*args, **kwargs)
+    # this can be accessed as $funcname(*args, **kwargs)
     # it must always accept *args and **kwargs.
     ...
     return something
@@ -31,7 +31,7 @@ def funcname(*args, **kwargs):
 Usage:
 
 ```python
-from evennia.utils.funcparser
+from evennia.utils.funcparser import FuncParser
 
 parser = FuncParser("path.to.module_with_callables")
 result = parser.parse("String with $funcname() in it")
@@ -1097,7 +1097,7 @@ def funcparser_callable_you(
 
     Examples:
         This can be used by the say or emote hooks to pass actor stance
-        strings. This should usually be combined with the $inflect() callable.
+        strings. This should usually be combined with the $conj() callable.
 
         - `With a grin, $you() $conj(jump) at $you(tommy).`
 
@@ -1181,7 +1181,7 @@ def funcparser_callable_conjugate(*args, caller=None, receiver=None, **kwargs):
 def funcparser_callable_pronoun(*args, caller=None, receiver=None, capitalize=False, **kwargs):
     """
 
-    Usage: $prop(word, [options])
+    Usage: $pron(word, [options])
 
     Adjust pronouns to the expected form. Pronouns are words you use instead of a
     proper name, such as 'him', 'herself', 'theirs' etc. These look different
@@ -1217,7 +1217,7 @@ def funcparser_callable_pronoun(*args, caller=None, receiver=None, capitalize=Fa
     `male`/`female`/`neutral`/`plural` (plural is considered a gender for this purpose).
     If no `gender` property/callable is found, `neutral` is used as a fallback.
 
-    The pronoun-type default (if not spefified in call) is `subject pronoun`.
+    The pronoun-type default (if not specified in call) is `subject pronoun`.
 
     Args:
         pronoun (str): Input argument to parsed call. This can be any of the pronouns
@@ -1287,7 +1287,7 @@ def funcparser_callable_pronoun(*args, caller=None, receiver=None, capitalize=Fa
     default_viewpoint = "2nd person"
 
     if hasattr(caller, "gender"):
-        if callable(caller, gender):
+        if callable(caller.gender):
             default_gender = caller.gender()
         else:
             default_gender = caller.gender
@@ -1315,7 +1315,7 @@ def funcparser_callable_pronoun_capitalize(
     *args, caller=None, receiver=None, capitalize=True, **kwargs
 ):
     """
-    Usage: $Pron(word) - always maps to a capitalized word.
+    Usage: $Pron(word, [options]) - always maps to a capitalized word.
 
     """
     return funcparser_callable_pronoun(


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] Global scripts are not being started, only restarted.
#### Describe the bug
When creating a new game, global scripts are not automatically started.

#### To Reproduce
Steps to reproduce the behavior:
1. Create a new game dir.
2. Create a script with `at_repeat` and add it to your server conf.
3. `evennia migrate` and `evennia start`
4. Check global scripts status.
5. See error

#### Expected behavior
Global scripts are supposed to start automatically.

#### Develop-branch commit
f093c8bcb

#### Additional context
I used the following dict in my settings:
```python
GLOBAL_SCRIPTS = {
                "test_script": {
                        "typeclass": "typeclasses.scripts.TestScript",
                        "persistent": True,
                        "interval": 20,
                        "desc": "Testing script starting and iteration."
                },

        }
```
And the following script class:
```python
class TestScript(Script):

    def at_repeat(self):
        print("hey, listen")
```

The script loaded correctly, and I was able to manually start it. After fully stopping and then starting the server, the script was automatically started again.

However, if I create a new game, start the server, and I _don't_ manually start the script, then fully stopping and then starting the server again does _not_ automatically start the script.


Discussion:

Resolving patch:
diff --git a/evennia/utils/containers.py b/evennia/utils/containers.py
--- a/evennia/utils/containers.py
+++ b/evennia/utils/containers.py
@@ -167,7 +167,7 @@ def _load_script(self, key):
 
             # store a hash representation of the setup
             script.attributes.add("_global_script_settings", compare_hash, category="settings_hash")
-            script.start()
+        script.start()
 
         return script
 


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] `rpsystem` object search can't handle duplicate names
#### Describe the bug
When there are two or more objects of the same name in a list of candidates (e.g. the default of a character's contents and location's contents), only the first one is located.

#### To Reproduce
Steps to reproduce the behavior:
1. Inherit from the `ContribRP` classes on your `Object` and `Character` class.
2. `create test object`
3. `create test object` again
4. `py self.contents` to confirm both are there
5. `py self.search("test object")` and `py self.search("test object", quiet=True)`
6. See error

#### Expected behavior
It should give a multi-match error, or return all matching objects if `quiet=True`.

#### Develop-branch commit
f093c8bcb



Discussion:
I went in to fix this so I could keep working on my own game and found the source of the problem.

For some reason my objects aren't getting the `sdesc` handler attached (which is a separate issue) which results in the system using [the "legacy" object parser](https://github.com/evennia/evennia/blob/f093c8bcb1321a44e33003cf91cf9f565e028de7/evennia/contrib/rpg/rpsystem/rpsystem.py#L302-329).

This builds a regex tuple based on an object's key and adds it to the cache, but only if a tuple with the same key doesn't already exist. Thus, if multiple "legacy" objects have the same key, it parses the key to the cached tuple for only the first object, resulting in only that object being found.

***edit: I know I said that the `sdesc` handler not being attached is a separate issue, but I discovered that it isn't attached because... it isn't. _All_ non-Character objects have no sdesc handler, which means that this problem will arise for all non-Character objects with identical names and it isn't a legacy issue but a built-in one.

Resolving patch:
diff --git a/evennia/contrib/rpg/rpsystem/rpsystem.py b/evennia/contrib/rpg/rpsystem/rpsystem.py
--- a/evennia/contrib/rpg/rpsystem/rpsystem.py
+++ b/evennia/contrib/rpg/rpsystem/rpsystem.py
@@ -319,14 +319,15 @@ def regex_tuple_from_key_alias(obj):
     """
     global _REGEX_TUPLE_CACHE
     permutation_string = " ".join([obj.key] + obj.aliases.all())
+    cache_key = f"{obj.id} {permutation_string}"
 
-    if permutation_string not in _REGEX_TUPLE_CACHE:
-        _REGEX_TUPLE_CACHE[permutation_string] = (
+    if cache_key not in _REGEX_TUPLE_CACHE:
+        _REGEX_TUPLE_CACHE[cache_key] = (
             re.compile(ordered_permutation_regex(permutation_string), _RE_FLAGS),
             obj,
             obj.key,
         )
-    return _REGEX_TUPLE_CACHE[permutation_string]
+    return _REGEX_TUPLE_CACHE[cache_key]
 
 
 def parse_language(speaker, emote):


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] `get_by_tag` category list fails on None
#### Describe the bug
When using a list for the `category` kwarg that contains an entry of `None` (which is a valid category), it fails with a traceback. Presumably due to the use of `sorted` here <https://github.com/evennia/evennia/blob/develop/evennia/typeclasses/managers.py#L289>

#### To Reproduce
Steps to reproduce the behavior:
1. Add tags to an object (e.g. a room), both with categories and without. Let's say:
```
tag here = test
tag here = tag1:cat1
tag here = tag2:cat2
```
2. `Room.objects.get_by_tag(key=["tag1","tag2"], category=["cat1","cat2"])` returns the current room
3. `Room.objects.get_by_tag(key=["tag1","test"], category=["cat1",None])` _should_ return the current room as well, but instead will traceback.

#### Expected behavior
Since `None` is a valid tag category, the function should be capable of searching for tags with categories of strings _and_ of `None`.

#### Develop-branch commit
7f4769bd9

#### Additional context
Traceback:
```
File "./evennia/evennia/typeclasses/managers.py", line 289, in get_by_tag
    unique_categories = sorted(set(categories))
TypeError: '<' not supported between instances of 'NoneType' and 'str'
```


Discussion:

Resolving patch:
diff --git a/evennia/typeclasses/managers.py b/evennia/typeclasses/managers.py
--- a/evennia/typeclasses/managers.py
+++ b/evennia/typeclasses/managers.py
@@ -286,7 +286,7 @@ def get_by_tag(self, key=None, category=None, tagtype=None, **kwargs):
         categories = make_iter(category) if category else []
         n_keys = len(keys)
         n_categories = len(categories)
-        unique_categories = sorted(set(categories))
+        unique_categories = set(categories)
         n_unique_categories = len(unique_categories)
 
         dbmodel = self.model.__dbclass__.__name__.lower()


Test patch:
diff --git a/evennia/typeclasses/tests.py b/evennia/typeclasses/tests.py
--- a/evennia/typeclasses/tests.py
+++ b/evennia/typeclasses/tests.py
@@ -142,6 +142,13 @@ def test_get_tag_with_any(self):
             [self.obj1],
         )
 
+    def test_get_tag_with_any_including_nones(self):
+        self.obj1.tags.add("tagA", "categoryA")
+        self.assertEqual(
+            self._manager("get_by_tag", ["tagA", "tagB"], ["categoryA", "categoryB", None], match="any"),
+            [self.obj1],
+        )
+
     def test_get_tag_withnomatch(self):
         self.obj1.tags.add("tagC", "categoryC")
         self.assertEqual(
Repository: evennia/evennia

Issue:
[BUG - Develop] `text` overrides `prompt` when in the same `msg` call
#### Describe the bug
According to [this How-To](https://www.evennia.com/docs/1.0-dev/Howtos/Command-Prompt.html), it's intended that you should be able to do `char.msg("a text message", prompt="some prompt text")` and have the server send both the normal message and also a prompt message.

However, all of the portals appears to be designed so that, if `prompt` is in the kwargs, it _replaces_ the `prompt` string with `text` and sends that as a prompt.

#### Expected behavior
I'd expect it to behave as described in the documentation, where it sends the text field as a regular text message and the prompt field as a prompt message.

Even if only one type of message could be sent at a time, in _no_ situation would I expect the `text` kwarg to replace the `prompt` kwarg and be sent in its place.

#### Develop-branch commit
6edf9064c

#### Additional context
It doesn't look too difficult to fix this, just a bit tedious, so I'll take a stab at it over the next week.


Discussion:

Resolving patch:
diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py
--- a/evennia/server/sessionhandler.py
+++ b/evennia/server/sessionhandler.py
@@ -269,7 +269,12 @@ def _validate(data):
                     rkwargs[key] = [_validate(data), {}]
             else:
                 rkwargs[key] = [[_validate(data)], {}]
-            rkwargs[key][1]["options"] = options
+            rkwargs[key][1]["options"] = dict(options)
+        # make sure that any "prompt" message will be processed last
+        # by moving it to the end
+        if "prompt" in rkwargs:
+            prompt = rkwargs.pop("prompt")
+            rkwargs["prompt"] = prompt
         return rkwargs
 
 


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] Can't `|` two SaverDicts
#### Describe the bug
When combining two attributes containing dict data, it fails with a traceback.
```
File "./TestGame/typeclasses/characters.py", line 30, in test_attr
return self.db.db_one | self.db.db_two
File "./evennia/evennia/utils/dbserialize.py", line 243, in __or__
return self._data | other
TypeError: unsupported operand type(s) for |: 'dict' and '_SaverDict
```

#### To Reproduce
Steps to reproduce the behavior:
1. Store dicts in two attributes or attribute properties.
2. Use the `|` operator on them
4. See error

#### Develop-branch commit
22fa2c6b8


Discussion:
Well, this one's easy - they just don't have an operator for using | (which feels pretty esoteric to do, honestly). 
@Griatch Esoteric? Isn't | the standard dict combination operator?

edit: It should be implemented, as of #2743 - it just doesn't work when both sides are SaverDicts
Ok, esoteric was the wrong term, but  it has at least not been a thing until Python 3.9+, which is why it was not originally in there. 🙂
Oh haha I completely forgot it was so recent! I hadn't really ever needed to combine dicts until I started messing around with splicing together prototype dicts in evennia, so it's the syntax I learned first for it.

Anyway, the main issue is that it works fine if you combine a normal dict and a saver dict, but breaks if you use two saver dicts. It's easy enough to work around by casting one or both to `dict` first so I don't think it's a priority, but since it tracebacked I figured I'd report it.
The 'traditional', pre-Python3.9 way of doing this is `dict1.update(dict2)`.
But yeah, it should be added of course.

Resolving patch:
diff --git a/evennia/utils/dbserialize.py b/evennia/utils/dbserialize.py
--- a/evennia/utils/dbserialize.py
+++ b/evennia/utils/dbserialize.py
@@ -243,6 +243,9 @@ def __gt__(self, other):
     def __or__(self, other):
         return self._data | other
 
+    def __ror__(self, other):
+        return self._data | other
+
     @_save
     def __setitem__(self, key, value):
         self._data.__setitem__(key, self._convert_mutables(value))


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] REST API endpoints for specialized Objects (e.g. Characters) don't work
#### Describe the bug
The endpoints for `characters`, `rooms` etc can't find any objects at all. When accessing a known Character by ID, e.g. `/api/characters/335` it returns `{'detail': 'not found'}` and when checking the list view at `/api/characters/` it returns a list of length 0.

The `objects` endpoint can locate the same objects just fine, however, so they're accessible by the API - the endpoints themselves are what's broken.

I believe the method of filtering by typeclass is broken. e.g.
https://github.com/evennia/evennia/blob/3992f37dada8ae9d495b7bdc087ff107e21e29aa/evennia/web/api/views.py#L115-L117

#### To Reproduce
Steps to reproduce the behavior:
1. Create a game with some objects, rooms, and characters.
2. Turn on the API by adding `REST_API_ENABLED = True` to settings
3. Authenticate and access the endpoints `/api/objects/` `/api/characters/` and `/api/rooms/`
4. See error

#### Expected behavior
I expected the endpoints to return the info for the relevant object, and to correctly return all existing objects of the endpoint type.

#### Develop-branch commit
3992f37da

#### Additional context
The regular `objects` endpoint and all of the non-Object endpoints such as `/api/accounts` and `/api/scripts` work as expected.


Discussion:

Resolving patch:
diff --git a/evennia/web/api/views.py b/evennia/web/api/views.py
--- a/evennia/web/api/views.py
+++ b/evennia/web/api/views.py
@@ -112,10 +112,7 @@ class CharacterViewSet(ObjectDBViewSet):
 
     """
 
-    queryset = DefaultCharacter.objects.typeclass_search(
-        DefaultCharacter.path, include_children=True
-    )
-    list_serializer_class = serializers.ObjectListSerializer
+    queryset = DefaultCharacter.objects.all_family()
 
 
 class RoomViewSet(ObjectDBViewSet):
@@ -124,8 +121,7 @@ class RoomViewSet(ObjectDBViewSet):
 
     """
 
-    queryset = DefaultRoom.objects.typeclass_search(DefaultRoom.path, include_children=True)
-    list_serializer_class = serializers.ObjectListSerializer
+    queryset = DefaultRoom.objects.all_family()
 
 
 class ExitViewSet(ObjectDBViewSet):
@@ -135,8 +131,7 @@ class ExitViewSet(ObjectDBViewSet):
 
     """
 
-    queryset = DefaultExit.objects.typeclass_search(DefaultExit.path, include_children=True)
-    list_serializer_class = serializers.ObjectListSerializer
+    queryset = DefaultExit.objects.all_family()
 
 
 class AccountDBViewSet(TypeclassViewSetMixin, ModelViewSet):


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] Log rotation infinite-loops
#### Describe the bug
My log file reached the maximum size and when trying to rotate, it hits an infinite loop.

https://github.com/evennia/evennia/blob/3992f37dada8ae9d495b7bdc087ff107e21e29aa/evennia/utils/logger.py#L352-L354

I think maybe it's supposed to be `super().rotate()` instead of `self.rotate()`?

#### Develop-branch commit
3992f37da


Discussion:
D'oh, yes of course :/ 

Resolving patch:
diff --git a/evennia/utils/logger.py b/evennia/utils/logger.py
--- a/evennia/utils/logger.py
+++ b/evennia/utils/logger.py
@@ -351,7 +351,7 @@ def suffix(self, tupledate):
 
     def rotate(self):
         try:
-            self.rotate()
+            super().rotate()
         except Exception:
             log_trace(f"Could not rotate the log file {self.name}.")
 


Test patch:
Repository: evennia/evennia

Issue:
[BUG - Develop] `obj.tags.has` no longer returns `False` when tag is not present
#### Describe the bug
When checking for the presence of a tag, the `has` method no longer returns `False` for tags that are not present on the object. It only returns `True` matches or nothing.

#### To Reproduce
Steps to reproduce the behavior:
1. Open the `py` console within a clean game.
2. `self.tags.add("sitting")` and `self.tags.add("hungry")`
3. `self.tags.has("sitting")` will return `True`
4. `self.tags.has("kneeling")` will return an empty list
5. `self.tags.has(["sitting", "kneeling", "hungry"])` will return `[True, True]`

#### Expected behavior
- `self.tags.has("kneeling")` should return `False`
- `self.tags.has(["sitting", "kneeling", "hungry"])` should return `[True, False, True]`

#### Develop-branch commit
b0f24f997

#### Additional context
This worked correctly several months ago, but I'm not sure how recently the bug was introduced.


Discussion:

Resolving patch:
diff --git a/evennia/typeclasses/tags.py b/evennia/typeclasses/tags.py
--- a/evennia/typeclasses/tags.py
+++ b/evennia/typeclasses/tags.py
@@ -419,7 +419,7 @@ def has(self, key=None, category=None, return_list=False):
         if key:
             for tag_str in make_iter(key):
                 tag_str = tag_str.strip().lower()
-                ret.extend(bool(tag) for tag in self._getcache(tag_str, category))
+                ret.append(bool(self._getcache(tag_str, category)))
         elif category:
             ret.extend(bool(tag) for tag in self._getcache(category=category))
         else:


Test patch: