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

Issue:
[BUG] RPsystem contrib breaks dbrefs
#### Describe the bug
I installed the rpsystem contrib as instructed and it works as intended. But now when I try to find or use #dbrefs, it fails to acknowledge them. Here is an example of the problem: 
![image](https://github.com/evennia/evennia/assets/137568434/315ae4c2-043e-4644-b8ea-338c5b461f90)

#### To Reproduce
Steps to reproduce the behavior:
1. Install evennia.contrib.rpg.rpsystem
2. Try to find, look, desc or delete an item by its #dbref
3. See error


#### Expected behavior
It should show me the correct object/character/room and allow me to trigger commands using the #dbref as it did before.

#### Environment, Evennia version, OS etc
Evennia: 3.2.0
OS: Windows 10
Python: 3.10.6
Twisted: 23.10.0
Django: 4.2.10

#### Additional context
The #dbrefs worked perfectly prior to installing rpsystem, so I'm confident it has to do with that. I admit I'm not very savvy with python or evennia, so there is every possibility of user error. But I did install it correctly - to the best of my knowledge. Here are the relevant files I changed to install rpsystem so you can confirm if it was done correctly: https://github.com/Aeliffa/evenniahelp


Discussion:
I've confirmed this is a problem with the custom search, likely introduced in one of the recent changes to the search function.

Here are the simplified reproduction steps pinpointing it:

1. Inherit from `ContribRPCharacter` on your `Character` class in `typeclasses/characters.py` as per the install instructions.
2. DON'T do any other installation steps.
3. Attempt to interact with any object by dbref - it will fail to find it.

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
@@ -1320,12 +1320,7 @@ def at_object_creation(self):
     def get_search_result(
         self,
         searchdata,
-        attribute_name=None,
-        typeclass=None,
         candidates=None,
-        exact=False,
-        use_dbref=None,
-        tags=None,
         **kwargs,
     ):
         """
@@ -1352,12 +1347,12 @@ def get_search_result(
 
             if not results and is_builder:
                 # builders get a chance to search only by key+alias
-                results = search_obj(searchdata)
+                results = search_obj(searchdata, candidates=candidates, **kwargs)
         else:
             # global searches / #drefs end up here. Global searches are
             # only done in code, so is controlled, #dbrefs are turned off
             # for non-Builders.
-            results = search_obj(searchdata)
+            results = search_obj(searchdata, **kwargs)
         return results
 
     def get_posed_sdesc(self, sdesc, **kwargs):


Test patch:
Repository: evennia/evennia

Issue:
[BUG] 'get' 'drop' and 'give' throw an exception if no arguments are given
#### Describe the bug

The commands `get` `drop` and `give` throw an exception if no object is specified:
```
>get
Traceback (most recent call last):
  File "/home/chiizujin/Data/Source/Python/Evennia-contrib/evennia/evennia/commands/c
mdhandler.py", line 624, in _run_command
    yield cmd.parse()
          ^^^^^^^^^^^
  File "/home/chiizujin/Data/Source/Python/Evennia-contrib/evennia/evennia/commands/d
efault/general.py", line 402, in parse
    count, *args = self.lhs.split(maxsplit=1)
    ^^^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
```
#### Expected behavior

An error message should be given.

#### Additional context

The `func` methods heve guards, such as
```
if not self.args:
    self.msg("Get what?")
    return
```
...but the error is happening in `parse`, before `func` is called.


Discussion:

Resolving patch:
diff --git a/evennia/commands/default/general.py b/evennia/commands/default/general.py
--- a/evennia/commands/default/general.py
+++ b/evennia/commands/default/general.py
@@ -397,7 +397,7 @@ def parse(self):
         """
         super().parse()
         self.number = 0
-        if hasattr(self, "lhs"):
+        if getattr(self, "lhs", None):
             # handle self.lhs but don't require it
             count, *args = self.lhs.split(maxsplit=1)
             # we only use the first word as a count if it's a number and


Test patch:
diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py
--- a/evennia/commands/default/tests.py
+++ b/evennia/commands/default/tests.py
@@ -134,6 +134,17 @@ def test_give(self):
         self.obj2.location = self.char1
         self.call(general.CmdGive(), "2 Obj = Char2", "You give two Objs")
 
+    def test_numbered_target_command(self):
+        class CmdTest(general.NumberedTargetCommand):
+            key = "test"
+
+            def func(self):
+                self.msg(f"Number: {self.number} Args: {self.args}")
+
+        self.call(CmdTest(), "", "Number: 0 Args: ")
+        self.call(CmdTest(), "obj", "Number: 0 Args: obj")
+        self.call(CmdTest(), "1 obj", "Number: 1 Args: obj")
+
     def test_mux_command(self):
         class CmdTest(MuxCommand):
             key = "test"
Repository: DataDog/integrations-core

Issue:
[couch] error "local variable 'db_stats' referenced before assignment"
I just started using datadog and have an issue getting the couch integration to run (on MacOS Sierra). 

 `/usr/local/bin/datadog-agent info` reports this:

````
 Checks
  ======

    ntp
    ---
      - Collected 0 metrics, 0 events & 1 service check

    disk
    ----
      - instance #0 [OK]
      - Collected 44 metrics, 0 events & 1 service check

    network
    -------
      - instance #0 [OK]
      - Collected 27 metrics, 0 events & 1 service check

    couch
    -----
      - instance #0 [ERROR]: "local variable 'db_stats' referenced before assignment"
      - Collected 0 metrics, 0 events & 2 service checks


  Emitters
  ========

    - http_emitter [OK]

===================
Dogstatsd (v 5.8.0)
===================

  Status date: 2017-02-22 17:11:34 (8s ago)
  Pid: 85989
  Platform: Darwin-16.4.0-x86_64-i386-64bit
  Python Version: 2.7.11, 64bit
````

To me, `local variable 'db_stats' referenced before assignment` looks like an error in the couchdb integration library.


Discussion:
I managed to get the integration running by whitelisting single databases. I have more than 100 databases, and many of them include a forward slash in their name. These database names have to be URI encoded, so e.g. `users/bernhard` must be encoded like `users%2Fbernhard`. Probably this encoding is the problem, and subsequently the error handler in checks.py throws an exception because there is no `db_stats` var.

Resolving patch:
diff --git a/couch/check.py b/couch/check.py
--- a/couch/check.py
+++ b/couch/check.py
@@ -4,6 +4,7 @@
 
 # stdlib
 from urlparse import urljoin
+from urllib import quote
 
 # 3rd party
 import requests
@@ -119,7 +120,7 @@ def get_data(self, server, instance):
             databases = list(databases)[:self.MAX_DB]
 
         for dbName in databases:
-            url = urljoin(server, dbName)
+            url = urljoin(server, quote(dbName, safe = ''))
             try:
                 db_stats = self._get_stats(url, instance)
             except requests.exceptions.HTTPError as e:


Test patch:
Repository: DataDog/integrations-core

Issue:
postfix integration should not require sudo to root
Reading the source code to integrations-core/postfix/check.py I note that it does a sudo to root to run the find command.

This is noted in the docs / comments :

> WARNING: the user that dd-agent runs as must have sudo access for the 'find' command
> --
>   | sudo access is not required when running dd-agent as root (not recommended)
>   |  
>   | example /etc/sudoers entry:
>   | dd-agent ALL=(ALL) NOPASSWD:/usr/bin/find /var/spool/postfix* -type f

root should not be required here - postfix user should be sufficient. That would be combined with a '-u postfix' on line 64's sudo command to allow this to work.

This is a concern because find has a -exec parameter and your command list has a wildcard in it - this could be used to run arbitrary commands as root if the dd-agent user is compromised.



Discussion:
More to the point, what was wrong with just running mailq?

Resolving patch:
diff --git a/postfix/check.py b/postfix/check.py
--- a/postfix/check.py
+++ b/postfix/check.py
@@ -17,7 +17,9 @@ class PostfixCheck(AgentCheck):
              sudo access is not required when running dd-agent as root (not recommended)
 
     example /etc/sudoers entry:
-             dd-agent ALL=(ALL) NOPASSWD:/usr/bin/find /var/spool/postfix* -type f
+        dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/incoming -type f
+        dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/active -type f
+        dd-agent ALL=(postfix) NOPASSWD:/usr/bin/find /var/spool/postfix/deferred -type f
 
     YAML config options:
         "directory" - the value of 'postconf -h queue_directory'
@@ -61,7 +63,9 @@ def _get_queue_count(self, directory, queues, tags):
                 # can dd-agent user run sudo?
                 test_sudo = os.system('setsid sudo -l < /dev/null')
                 if test_sudo == 0:
-                    output, _, _ = get_subprocess_output(['sudo', 'find', queue_path, '-type', 'f'], self.log, False)
+                    # default to `root` for backward compatibility
+                    postfix_user = self.init_config.get('postfix_user', 'root')
+                    output, _, _ = get_subprocess_output(['sudo', '-u', postfix_user, 'find', queue_path, '-type', 'f'], self.log, False)
                     count = len(output.splitlines())
                 else:
                     raise Exception('The dd-agent user does not have sudo access')


Test patch:
Repository: DataDog/integrations-core

Issue:
Bug in network check
On this line:
https://github.com/DataDog/integrations-core/blob/master/network/check.py#L438

This should be `self.log` rather than `self.logger`.  As it is, this raises
```
AttributeError: 'Network' object has no attribute 'logger'
```


Discussion:
Thank you @alertedsnake! Good eye, we'll try to get that fixed ASAP.

Resolving patch:
diff --git a/network/check.py b/network/check.py
--- a/network/check.py
+++ b/network/check.py
@@ -435,7 +435,7 @@ def _check_bsd(self, instance):
             #          -7       -6       -5        -4       -3       -2        -1
             for h in ("Ipkts", "Ierrs", "Ibytes", "Opkts", "Oerrs", "Obytes", "Coll"):
                 if h not in headers:
-                    self.logger.error("%s not found in %s; cannot parse" % (h, headers))
+                    self.log.error("%s not found in %s; cannot parse" % (h, headers))
                     return False
 
             current = None


Test patch:
Repository: ethereum/web3.py

Issue:
Transform Markdown on PyPi release
### What was wrong?

README is not readable on PyPI: https://pypi.python.org/pypi/web3/1.4.0

`setuptools-markdown` allows to publish README.md on PyPi
- https://pypi.python.org/pypi/setuptools-markdown
#### Cute Animal Picture

![Koala](http://i.imgur.com/Y3FZh.jpg)



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,12 +32,13 @@
     name='web3',
     version='3.13.5',
     description="""Web3.py""",
-    long_description=readme,
+    long_description_markdown_filename='README.md',
     author='Piper Merriam',
     author_email='pipermerriam@gmail.com',
     url='https://github.com/pipermerriam/web3.py',
     include_package_data=True,
     install_requires=install_requires,
+    setup_requires=['setuptools-markdown'],
     extras_require={
         'tester': ["eth-testrpc>=1.2.0"],
         'gevent': [


Test patch:
Repository: ethereum/web3.py

Issue:
Changes to web3.eth.estimateGas
Check whether 'from' parameter is already in transaction and use it. Otherwise use defaultAccount.
Basically to implement the same behavior as for 'sendTransaction'.



Discussion:

Resolving patch:
diff --git a/web3/eth.py b/web3/eth.py
--- a/web3/eth.py
+++ b/web3/eth.py
@@ -255,7 +255,7 @@ def call(self, transaction, block_identifier=None):
 
     def estimateGas(self, transaction):
         # TODO: move to middleware
-        if is_address(self.defaultAccount):
+        if 'from' not in transaction and is_address(self.defaultAccount):
             transaction = assoc(transaction, 'from', self.defaultAccount)
 
         return self.web3.manager.request_blocking(


Test patch:
Repository: ethereum/web3.py

Issue:
Remove shh from default list of modules
The whisper protocol is not standardized enough to be in the default list.

Also, note in the docs the current fractured nature of whisper.

See #384 


Discussion:

Resolving patch:
diff --git a/web3/main.py b/web3/main.py
--- a/web3/main.py
+++ b/web3/main.py
@@ -18,7 +18,6 @@
 from web3.miner import Miner
 from web3.net import Net
 from web3.personal import Personal
-from web3.shh import Shh
 from web3.testing import Testing
 from web3.txpool import TxPool
 from web3.version import Version
@@ -53,7 +52,6 @@
 def get_default_modules():
     return {
         "eth": Eth,
-        "shh": Shh,
         "net": Net,
         "personal": Personal,
         "version": Version,


Test patch:
Repository: ethereum/web3.py

Issue:
Add field name of formatter failure to apply_formatters_to_dict
* Version: 3.x & 4.x
* Python: 2.7/3.4/3.5
* OS: osx/linux/win


### What was wrong?

When applying formatters to a dict, if one of the values fails, it's impossible to tell from the trace which one did.

### How can it be fixed?

Catch ValueError exceptions in `apply_formatters_to_dict` and rethrow with the name of the field that failed.


Discussion:

Resolving patch:
diff --git a/web3/utils/formatters.py b/web3/utils/formatters.py
--- a/web3/utils/formatters.py
+++ b/web3/utils/formatters.py
@@ -67,7 +67,10 @@ def apply_formatter_if(condition, formatter, value):
 def apply_formatters_to_dict(formatters, value):
     for key, item in value.items():
         if key in formatters:
-            yield key, formatters[key](item)
+            try:
+                yield key, formatters[key](item)
+            except (TypeError, ValueError) as exc:
+                raise type(exc)("Could not format value %r as field %r" % (item, key)) from exc
         else:
             yield key, item
 


Test patch:
diff --git a/tests/core/utilities/test_formatters.py b/tests/core/utilities/test_formatters.py
--- a/tests/core/utilities/test_formatters.py
+++ b/tests/core/utilities/test_formatters.py
@@ -2,6 +2,7 @@
 import pytest
 
 from web3.utils.formatters import (
+    apply_formatters_to_dict,
     map_collection,
     recursive_map,
 )
@@ -39,3 +40,12 @@ def test_recursive_collection_cycle():
     data.append(data)
     with pytest.raises(ValueError):
         recursive_map(square_int, data)
+
+
+def test_format_dict_error():
+    with pytest.raises(ValueError) as exc_info:
+        apply_formatters_to_dict(
+            {'myfield': int},
+            {'myfield': 'a'},
+        )
+    assert 'myfield' in str(exc_info.value)
Repository: ethereum/web3.py

Issue:
Use EthereumTesterProvider backed by eth-tester in default import
`from web3 import EthereumTesterProvider` should use the eth-tester one, not the testrpc one.


Discussion:

Resolving patch:
diff --git a/web3/__init__.py b/web3/__init__.py
--- a/web3/__init__.py
+++ b/web3/__init__.py
@@ -9,9 +9,11 @@
 from web3.providers.rpc import (  # noqa: E402
     HTTPProvider,
 )
+from web3.providers.eth_tester import (  # noqa: E402
+    EthereumTesterProvider,
+)
 from web3.providers.tester import (  # noqa: E402
     TestRPCProvider,
-    EthereumTesterProvider,
 )
 from web3.providers.ipc import (  # noqa: E402
     IPCProvider,


Test patch:
Repository: ethereum/web3.py

Issue:
Incorrect return value example for web3.personal.newAccount
http://web3py.readthedocs.io/en/stable/web3.personal.html?highlight=newAccount#web3.personal.newAccount

The documentation provides the following example:

```
>>> web3.personal.newAccount('the-passphrase')
['0xd3cda913deb6f67967b99d67acdfa1712c293601']
```

However, the return value is the address as a string, not an array containing it:

```
>>> web3.personal.newAccount('the-passphrase')
'0xd3cda913deb6f67967b99d67acdfa1712c293601'
```


Discussion:
:+1: doc bug

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -28,6 +28,7 @@
         "websockets>=4.0.1",
     ],
     setup_requires=['setuptools-markdown'],
+    python_requires='>=3.5, <4',
     extras_require={
         'tester': [
             "eth-tester[py-evm]==0.1.0-beta.23",
@@ -48,7 +49,7 @@
     keywords='ethereum',
     packages=find_packages(exclude=["tests", "tests.*"]),
     classifiers=[
-        'Development Status :: 4 - Beta',
+        'Development Status :: 5 - Production/Stable',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
         'Natural Language :: English',


Test patch:
Repository: ethereum/web3.py

Issue:
createFilter event syntax does not work while eventFilter works
* Version: 4.2.0
* Python: 3.6
* OS: linux

### What was wrong?
Filtering for an event with Syntax 2 does not work, while the deprecated Syntax 1 works:

Syntax 1:
```python
event_filt= instance.eventFilter(
        'EventName',
        {
            'fromBlock': 0,
            'toBlock': 'latest',
        })
```

Syntax 2
```python
event_filt = instance.events.EventName.createFilter(fromBlock=0, toBlock='latest')
```

### How can it be fixed?
By inspecting `event_filt.filter_params`, when using Syntax 2, the `address` field is populated with a list which includes the contract address twice. This happens because in the following snippet, the call is made to `construct_event_filter_params` with both `address` and `contract_address` which have the same value. 

https://github.com/ethereum/web3.py/blob/ee8e217fec8231e6262473d1f72fa9dad68ff3c8/web3/contract.py#L1211-L1219

Commenting out contract.py:1217 solves the issue for me. 
If you are using ganache as a node you need to monkey-patch web3 to bypass trufflesuite/ganache-cli#494, and create the contract object with a lowercase address https://github.com/ethereum/web3.py/issues/674, https://github.com/jordanjambazov/web3.py/commit/a61b382dd5c11de1102779868d377408c7590839



Discussion:

Resolving patch:
diff --git a/web3/contract.py b/web3/contract.py
--- a/web3/contract.py
+++ b/web3/contract.py
@@ -1296,9 +1296,6 @@ def createFilter(
         if argument_filters is None:
             argument_filters = dict()
 
-        if not address:
-            address = self.address
-
         _filters = dict(**argument_filters)
 
         data_filter_set, event_filter_params = construct_event_filter_params(


Test patch:
diff --git a/tests/core/filtering/test_contract_on_event_filtering.py b/tests/core/filtering/test_contract_on_event_filtering.py
--- a/tests/core/filtering/test_contract_on_event_filtering.py
+++ b/tests/core/filtering/test_contract_on_event_filtering.py
@@ -1,9 +1,29 @@
 import pytest
 
+from eth_utils import (
+    is_address,
+)
+
 # Ignore warning in pyethereum 1.6 - will go away with the upgrade
 pytestmark = pytest.mark.filterwarnings("ignore:implicit cast from 'char *'")
 
 
+@pytest.mark.parametrize('call_as_instance', (True, False))
+def test_create_filter_address_parameter(web3, emitter, Emitter, call_as_instance):
+    if call_as_instance:
+        event_filter = emitter.events.LogNoArguments.createFilter(fromBlock="latest")
+    else:
+        event_filter = Emitter.events.LogNoArguments.createFilter(fromBlock="latest")
+
+    if call_as_instance:
+        # Assert this is a single string value, and not a list of addresses
+        assert isinstance(event_filter.filter_params['address'], str)
+        assert is_address(event_filter.filter_params['address'])
+    else:
+        #  Undeployed contract shouldnt have address...
+        assert 'address' not in event_filter.filter_params
+
+
 @pytest.mark.parametrize('call_as_instance', (True, False))
 def test_on_filter_using_get_entries_interface(
         web3,
Repository: ethereum/web3.py

Issue:
Upgrade to or add support for websockets v5
### What was wrong?

We are currently using the `websockets` library's v4 line.  The v5 line is out.

### How can it be fixed?

Look into adding support for both v4 and v5.

If this is too cumbersome, we can simply upgrade to requiring `>=v5`



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,7 @@
         "lru-dict>=1.1.6,<2.0.0",
         "eth-hash[pycryptodome]",
         "requests>=2.16.0,<3.0.0",
-        "websockets>=4.0.1,<5.0.0",
+        "websockets>=5.0.1,<6.0.0",
         "pypiwin32>=223;platform_system=='Windows'",
     ],
     setup_requires=['setuptools-markdown'],


Test patch:
Repository: ethereum/web3.py

Issue:
Add python 3.7 to CI tests
### What was wrong?
python 3.7 is out, and we should include it in our testing.


### How can it be fixed?

add python 3.7 to our tox.ini & circleci config



Discussion:
For ref: https://github.com/ethereum/py-evm/issues/970 - same-topic tracking issue in `py-evm`; with some initial findings - haven't revisited in 2 weeks.
`python3.7` support in `websockets` was added in `v6.0`. So `websocket` version has to be bumped in web3 to 6.0.
In #973, someone has already tested `HTTPProvider` with python3.7 and it seems functional. `websockets` might be the only library that might need a version upgrade.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -26,14 +26,14 @@
         "lru-dict>=1.1.6,<2.0.0",
         "eth-hash[pycryptodome]",
         "requests>=2.16.0,<3.0.0",
-        "websockets>=5.0.1,<6.0.0",
+        "websockets>=6.0.0,<7.0.0",
         "pypiwin32>=223;platform_system=='Windows'",
     ],
     setup_requires=['setuptools-markdown'],
     python_requires='>=3.5, <4',
     extras_require={
         'tester': [
-            "eth-tester[py-evm]==0.1.0-beta.30",
+            "eth-tester[py-evm]==0.1.0-beta.31",
             "py-geth>=2.0.1,<3.0.0",
         ],
         'testrpc': ["eth-testrpc>=1.3.3,<2.0.0"],


Test patch: