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

Issue:
not having a LASAIR token in Settings.py breaks
Fail more gracefully if no LASAIR token in settings.py


Discussion:

Resolving patch:
diff --git a/tom_alerts/brokers/lasair.py b/tom_alerts/brokers/lasair.py
--- a/tom_alerts/brokers/lasair.py
+++ b/tom_alerts/brokers/lasair.py
@@ -90,10 +90,15 @@ class LasairBroker(GenericBroker):
     form = LasairBrokerForm
 
     def fetch_alerts(self, parameters):
-        token = settings.LASAIR_TOKEN
         alerts = []
         broker_feedback = ''
         object_ids = ''
+        try:
+            token = settings.LASAIR_TOKEN
+        except AttributeError:
+            broker_feedback += 'Requires a LASAIR_TOKEN in settings.py. See https://lasair-ztf.lsst.ac.uk/api' \
+                               ' for details about how to acquire an authorization token.'
+            return iter(alerts), broker_feedback
 
         # Check for Cone Search
         if 'cone_ra' in parameters and len(parameters['cone_ra'].strip()) > 0 and\


Test patch:
Repository: OCA/bank-payment

Issue:
Code error in account_payment_sale
I'm reporting a bug in my own code : in the 7.0 branch, in account_payment_sale/model/sale.py line 41, we have the following code:

 partner.customer_payment_mode.id or False,

We should NOT have a coma at the end of this line. When we run the module in Odoo 8.0, it will crash when creating a sale order via a call to create because addons/sale/sale.py in odoo 8.0 silently plays the on_change and then it will try to create {"payment_mode_id: (False,)}, when leads to a crash



Discussion:
As I have updated 8.0 modules to new API in #35, error doesn't apply in that branch.


Resolving patch:
diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py
--- a/account_payment_sale/model/sale.py
+++ b/account_payment_sale/model/sale.py
@@ -38,7 +38,7 @@ def onchange_partner_id(self, cr, uid, ids, part, context=None):
             partner = self.pool['res.partner'].browse(
                 cr, uid, part, context=context)
             res['value']['payment_mode_id'] = \
-                partner.customer_payment_mode.id or False,
+                partner.customer_payment_mode.id or False
         else:
             res['value']['payment_mode_id'] = False
         return res


Test patch:
Repository: OCA/bank-payment

Issue:
Crash in account_payment_purchase
When you create an invoice from an incoming products on v7 with account_payment_purchase:

  File "/home/erp_super/erp/prod/src/addons/stock/stock.py", line 1153, in action_invoice_create
    invoice_vals = self._prepare_invoice(cr, uid, picking, partner, inv_type, journal_id, context=context)
  File "/home/erp_super/erp/prod/src/banking/account_payment_sale_stock/model/stock.py", line 34, in _prepare_invoice
    cr, uid, picking, partner, inv_type, journal_id, context=context)
  File "/home/erp_super/erp/prod/src/banking/account_payment_purchase/model/stock.py", line 38, in _prepare_invoice
    picking.purchase_id.supplier_partner_bank.id or False,
  File "/home/erp_super/erp/prod/src/server/openerp/osv/orm.py", line 504, in __getattr__
    raise AttributeError(e)
AttributeError: "Field 'supplier_partner_bank' does not exist in object 'browse_record(purchase.order, 774)'"

It seems that, when we decided to change to datamodel of the account_payment_\* modules, the file account_payment_purchase/model/stock.py was not changed !!! I'll do a PR to fix this.



Discussion:

Resolving patch:
diff --git a/account_payment_purchase/model/stock.py b/account_payment_purchase/model/stock.py
--- a/account_payment_purchase/model/stock.py
+++ b/account_payment_purchase/model/stock.py
@@ -35,8 +35,8 @@ def _prepare_invoice(
         if picking.purchase_id:
             invoice_vals.update({
                 'partner_bank_id':
-                picking.purchase_id.supplier_partner_bank.id or False,
-                'payment_mode_type':
-                picking.purchase_id.payment_mode_type.id or False,
+                picking.purchase_id.supplier_partner_bank_id.id or False,
+                'payment_mode_id':
+                picking.purchase_id.payment_mode_id.id or False,
                 })
         return invoice_vals


Test patch:
Repository: OCA/bank-payment

Issue:
Test fails with Odoo, not OCB
https://travis-ci.org/OCA/bank-payment/builds/47806067

File "/home/travis/build/OCA/bank-payment/account_direct_debit/models/account_invoice.py", line 140, in  __ init __
invoice_obj._columns['state'].selection.append(
KeyError: 'state'



Discussion:

Resolving patch:
diff --git a/account_direct_debit/models/account_invoice.py b/account_direct_debit/models/account_invoice.py
--- a/account_direct_debit/models/account_invoice.py
+++ b/account_direct_debit/models/account_invoice.py
@@ -126,7 +126,7 @@
 class AccountInvoice(orm.Model):
     _inherit = "account.invoice"
 
-    def __init__(self, pool, cr):
+    def _register_hook(self, cr):
         """
         Adding a state to the hardcoded state list of the inherited
         model. The alternative is duplicating the field definition
@@ -135,9 +135,7 @@ def __init__(self, pool, cr):
         Maybe apply a similar trick when overriding the buttons' 'states'
         attributes in the form view, manipulating the xml in fields_view_get().
         """
-        super(AccountInvoice, self).__init__(pool, cr)
-        invoice_obj = pool.get('account.invoice')
-        invoice_obj._columns['state'].selection.append(
+        self._columns['state'].selection.append(
             ('debit_denied', 'Debit denied'))
 
     def action_debit_denied(self, cr, uid, ids, context=None):


Test patch:
Repository: OCA/bank-payment

Issue:
[9.0] account_payment_order: propagate partner to offsetting account when possible
When the transfer move has one move line line per partner, it is useful to propagate the partner to the move line on the offsetting account.

@alexis-via do you agree?

https://github.com/OCA/bank-payment/blob/d2e87f74c04f413a793c7c12ec3d440bda6daf41/account_payment_order/models/account_payment_order.py#L358



Discussion:
:+1: for me

Mmm, I don't see real arguments against it (only that it doesn't behave the same way for grouped payments and non-grouped payments)... but I don't see real arguments in favor of it either. What real advantage do you see ?
But I'm not against it, you can move ahead.

Thinking about it more closely: if you write the partner on the move line in the bank account, it means that you will have to identify this partner on the bank statement line in order to reconcile it, which is a bit more work. In the countries where you have the bank account of the supplier/customer on the bank statement line, the partner is auto-detected so it's not more work, but for countries like France where this information is not available, it's a bit more work. Anyway, it's easy to inherit, so I'll be able to always write partner_id=False in the bank account move line if I want, thanks to the prepare methods. So it's not a problem for me if you change this.


Resolving patch:
diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py
--- a/account_payment_order/models/account_payment_order.py
+++ b/account_payment_order/models/account_payment_order.py
@@ -360,9 +360,17 @@ def _prepare_move_line_offsetting_account(
             account_id = self.journal_id.default_debit_account_id.id
         elif self.payment_mode_id.offsetting_account == 'transfer_account':
             account_id = self.payment_mode_id.transfer_account_id.id
+        partner_id = False
+        for index, bank_line in enumerate(bank_lines):
+            if index == 0:
+                partner_id = bank_line.payment_line_ids[0].partner_id.id
+            elif bank_line.payment_line_ids[0].partner_id.id != partner_id:
+                # we have different partners in the grouped move
+                partner_id = False
+                break
         vals = {
             'name': name,
-            'partner_id': False,
+            'partner_id': partner_id,
             'account_id': account_id,
             'credit': (self.payment_type == 'outbound' and
                        amount_company_currency or 0.0),


Test patch:
Repository: OCA/bank-payment

Issue:
[14.0] account_payment_purchase: changing many2one resets payment_mode
Hi,
We've seen that when the field purchase_vendor_bill_id is changed and a purchase is selected from it, the payment_mode_id is always reseted because it is using the reference purchase_id.
`new_mode = self.purchase_id.payment_mode_id.id or False`
We've made this change, and it seems to work as it should.
`new_mode = self.purchase_vendor_bill_id.purchase_order_id.payment_mode_id.id or False`
The same goes for the partner_bank_id field.
@MiquelRForgeFlow 


Discussion:

Resolving patch:
diff --git a/account_payment_purchase/models/account_invoice.py b/account_payment_purchase/models/account_invoice.py
--- a/account_payment_purchase/models/account_invoice.py
+++ b/account_payment_purchase/models/account_invoice.py
@@ -10,8 +10,16 @@ class AccountMove(models.Model):
 
     @api.onchange("purchase_vendor_bill_id", "purchase_id")
     def _onchange_purchase_auto_complete(self):
-        new_mode = self.purchase_id.payment_mode_id.id or False
-        new_bank = self.purchase_id.supplier_partner_bank_id.id or False
+
+        new_mode = (
+            self.purchase_vendor_bill_id.purchase_order_id.payment_mode_id.id
+            or self.purchase_id.payment_mode_id.id
+        )
+        new_bank = (
+            self.purchase_vendor_bill_id.purchase_order_id.supplier_partner_bank_id.id
+            or self.purchase_id.supplier_partner_bank_id.id
+        )
+
         res = super()._onchange_purchase_auto_complete() or {}
         if self.payment_mode_id and new_mode and self.payment_mode_id.id != new_mode:
             res["warning"] = {


Test patch:
Repository: ArchipelagoMW/Archipelago

Issue:
Reimplement /received
When merging code for items_handling, `/received` for TextClient got broken, because "can receive, but can't send" is not a thing anymore.

Actual implementation does not require a server update. I misremembered. no_location/tags and items_handling are completely separate.

\
-- original text below --

Proposed solution 1:
* allow items_handling 0b011
* have TextClient check server_version and send ConnectUpdate to 0b011
* /received automagically works

Proposed solution 2:
* as above, but send the ConnectUpdate when /received is being used the first time

Proposed solution 3:
* implement server-side
* make berserker unhappy
* ?
* profit




Discussion:
One of these days we might implement an inventory tab and/or hint tab. At which point the client needs inventory anyway.
i dont think we should add more bloat to the server, if the client no matter what client it is wants to know about received items, it should just always connect with item handling, i dont like the suggestion to send a connect update for it, as changing the item handling wont re-send all previsuly send items right?

Resolving patch:
diff --git a/CommonClient.py b/CommonClient.py
--- a/CommonClient.py
+++ b/CommonClient.py
@@ -723,7 +723,7 @@ def get_base_parser(description=None):
     class TextContext(CommonContext):
         tags = {"AP", "IgnoreGame", "TextOnly"}
         game = ""  # empty matches any game since 0.3.2
-        items_handling = 0  # don't receive any NetworkItems
+        items_handling = 0b111  # receive all items for /received
 
         async def server_auth(self, password_requested: bool = False):
             if password_requested and not self.password:


Test patch:
Repository: ArchipelagoMW/Archipelago

Issue:
Minecraft Randomizer
Adds support for randomizing Minecraft. 
- Requires the client-side mod found at [https://github.com/KonoTyran/Minecraft_AP_Randomizer](https://github.com/KonoTyran/Minecraft_AP_Randomizer) to communicate with the server. 
- Locations are Minecraft advancements; items are crafting recipes and various useful items. 
- Includes structure randomizer support for when the client supports it (currently disabled). 
- Includes full tests for item randomizer. 


Discussion:
Thank you!

Resolving patch:
diff --git a/MultiServer.py b/MultiServer.py
--- a/MultiServer.py
+++ b/MultiServer.py
@@ -761,7 +761,7 @@ async def on_client_connected(ctx: Context, client: Client):
         'datapackage_versions': {game: game_data["version"] for game, game_data
                                  in ctx.gamespackage.items() if game in games},
         'datapackage_checksums': {game: game_data["checksum"] for game, game_data
-                                  in ctx.gamespackage.items() if game in games},
+                                  in ctx.gamespackage.items() if game in games and "checksum" in game_data},
         'seed_name': ctx.seed_name,
         'time': time.time(),
     }])
diff --git a/WebHostLib/customserver.py b/WebHostLib/customserver.py
--- a/WebHostLib/customserver.py
+++ b/WebHostLib/customserver.py
@@ -94,7 +94,7 @@ def load(self, room_id: int):
 
         multidata = self.decompress(room.seed.multidata)
         game_data_packages = {}
-        for game in list(multidata["datapackage"]):
+        for game in list(multidata.get("datapackage", {})):
             game_data = multidata["datapackage"][game]
             if "checksum" in game_data:
                 if self.gamespackage.get(game, {}).get("checksum") == game_data["checksum"]:
@@ -102,8 +102,9 @@ def load(self, room_id: int):
                     # games package could be dropped from static data once all rooms embed data package
                     del multidata["datapackage"][game]
                 else:
-                    data = Utils.restricted_loads(GameDataPackage.get(checksum=game_data["checksum"]).data)
-                    game_data_packages[game] = data
+                    row = GameDataPackage.get(checksum=game_data["checksum"])
+                    if row:  # None if rolled on >= 0.3.9 but uploaded to <= 0.3.8. multidata should be complete
+                        game_data_packages[game] = Utils.restricted_loads(row.data)
 
         return self._load(multidata, game_data_packages, True)
 


Test patch:
Repository: ArchipelagoMW/Archipelago

Issue:
fixed !missing to point to location table not item.



Discussion:
Thank you!

Resolving patch:
diff --git a/MultiServer.py b/MultiServer.py
--- a/MultiServer.py
+++ b/MultiServer.py
@@ -260,7 +260,8 @@ def _load_game_data(self):
 
     def _init_game_data(self):
         for game_name, game_package in self.gamespackage.items():
-            self.checksums[game_name] = game_package["checksum"]
+            if "checksum" in game_package:
+                self.checksums[game_name] = game_package["checksum"]
             for item_name, item_id in game_package["item_name_to_id"].items():
                 self.item_names[item_id] = item_name
             for location_name, location_id in game_package["location_name_to_id"].items():
@@ -268,7 +269,7 @@ def _init_game_data(self):
             self.all_item_and_group_names[game_name] = \
                 set(game_package["item_name_to_id"]) | set(self.item_name_groups[game_name])
             self.all_location_and_group_names[game_name] = \
-                set(game_package["location_name_to_id"]) | set(self.location_name_groups[game_name])
+                set(game_package["location_name_to_id"]) | set(self.location_name_groups.get(game_name, []))
 
     def item_names_for_game(self, game: str) -> typing.Optional[typing.Dict[str, int]]:
         return self.gamespackage[game]["item_name_to_id"] if game in self.gamespackage else None
@@ -356,9 +357,7 @@ def notify_client_multiple(self, client: Client, texts: typing.List[str], additi
                                    [{"cmd": "PrintJSON", "data": [{ "text": text }], **additional_arguments}
                                     for text in texts]))
 
-
     # loading
-
     def load(self, multidatapath: str, use_embedded_server_options: bool = False):
         if multidatapath.lower().endswith(".zip"):
             import zipfile
@@ -446,9 +445,10 @@ def _load(self, decoded_obj: dict, game_data_packages: typing.Dict[str, typing.A
             logging.info(f"Loading embedded data package for game {game_name}")
             self.gamespackage[game_name] = data
             self.item_name_groups[game_name] = data["item_name_groups"]
-            self.location_name_groups[game_name] = data["location_name_groups"]
+            if "location_name_groups" in data:
+                self.location_name_groups[game_name] = data["location_name_groups"]
+                del data["location_name_groups"]
             del data["item_name_groups"]  # remove from data package, but keep in self.item_name_groups
-            del data["location_name_groups"]
         self._init_game_data()
         for game_name, data in self.item_name_groups.items():
             self.read_data[f"item_name_groups_{game_name}"] = lambda lgame=game_name: self.item_name_groups[lgame]


Test patch:
Repository: ros/ros_comm

Issue:
roslaunch --files prints error if multiple anon nodes have same id
When running:

```
roslaunch --files package_name launch_file.launch
```

I get the following error:

```
roslaunch file contains multiple nodes named [/$(anon foo)].
Please check all <node> 'name' attributes to make sure they are unique.
Also check that $(anon id) use different ids.
```

Note that when actually launching the launch file, this will not be a problem because the anonymous node names will be expanded with unique suffixes.  Also, the list of files does not relate to the expansion of anonymous node names, so the file list should be printable regardless.

This is similar in spirit to bugs #94 and #65, both of which suffer because roslaunch simply prints an error and quits when it finds non-unique node names instead of doing as much as possible to help you find your error.



Discussion:
I have a fix for this, by the way, I'm just trying to get the pull request together.


Resolving patch:
diff --git a/tools/roslaunch/src/roslaunch/rlutil.py b/tools/roslaunch/src/roslaunch/rlutil.py
--- a/tools/roslaunch/src/roslaunch/rlutil.py
+++ b/tools/roslaunch/src/roslaunch/rlutil.py
@@ -235,7 +235,7 @@ def print_file_list(roslaunch_files):
     from roslaunch.config import load_config_default, get_roscore_filename
     import roslaunch.xmlloader
     try:
-        loader = roslaunch.xmlloader.XmlLoader(resolve_anon=False)
+        loader = roslaunch.xmlloader.XmlLoader(resolve_anon=True)
         config = load_config_default(roslaunch_files, None, loader=loader, verbose=False, assign_machines=False)
         files = [os.path.abspath(x) for x in set(config.roslaunch_files) - set([get_roscore_filename()])]
         print('\n'.join(files))


Test patch:
Repository: ros/ros_comm

Issue:
rospy nodes are hard to kill if master is not running
If you run a node before starting the master, you get the expected message:

```
Unable to register with master node [http://localhost:11311]: master may not be running yet. Will keep trying.
```

However, it doesn't respond to Ctrl-C or kill commands. The only way to stop it is to find the pid and use kill -9.



Discussion:
Could you please mention for which ROS distro you experience?

When I run `rosrun rospy_tutorials talker.py` on Groovy I get the expected message but Ctrl+C works perfectly fine for me there. Can you post which specific node you run which is not abortable?

Sorry, I'm on groovy. And I can confirm that talker.py works as expected. But I was using the visualization_tutorials, i.e. `rosrun interactive_marker_tutorials basic_controls.py`, and it can't be killed. Oddly, even if I wrap `rospy.init_node("basic_controls")` in a try / except, no exception gets thrown. I suspect I'm just missing something here...

A better example - notice that although talker.py behaves as expected, listener.py does not.


Resolving patch:
diff --git a/clients/rospy/src/rospy/impl/registration.py b/clients/rospy/src/rospy/impl/registration.py
--- a/clients/rospy/src/rospy/impl/registration.py
+++ b/clients/rospy/src/rospy/impl/registration.py
@@ -51,7 +51,7 @@
 except ImportError:
     import xmlrpclib as xmlrpcclient
 
-from rospy.core import is_shutdown, xmlrpcapi, \
+from rospy.core import is_shutdown, is_shutdown_requested, xmlrpcapi, \
     logfatal, logwarn, loginfo, logerr, logdebug, \
     signal_shutdown, add_preshutdown_hook
 from rospy.names import get_caller_id, get_namespace
@@ -162,8 +162,17 @@ def clear(self):
         """
         Remove all registration listeners
         """
-        with self.lock:
+        if not is_shutdown_requested():
+            with self.lock:
+                del self.listeners[:]
+        else:
+            # when being in shutdown phase the lock might not be lockable
+            # if a notify_added/removed is currently ongoing
+            locked = self.lock.acquire(False)
+            # remove all listeners anyway
             del self.listeners[:]
+            if locked:
+                self.lock.release()
             
 _registration_listeners = RegistrationListeners()
 def get_registration_listeners():


Test patch:
Repository: ros/ros_comm

Issue:
roslaunch does not accept a package name if a file with the same name exists in the current directory
Reproduce with:

```
roscreate-pkg roslaunch_test
cd roslaunch_test
mkdir bin
mkdir launch
touch bin/roslaunch_test
echo "<launch/>" > launch/example.launch
cd bin
roslaunch roslaunch_test example.launch
```

Error output:

```
Usage: roslaunch [options] [package] <filename> [arg_name:=value...]

roslaunch: error: The following input files do not exist: example.launch
```

Without the file in `bin/` or with another working directory roslaunch executes without errors (and exits immediately as there are no nodes).

I am using roslaunch 1.9.47 installed from the binary package repository in ROS hydro.



Discussion:

Resolving patch:
diff --git a/tools/roslaunch/src/roslaunch/rlutil.py b/tools/roslaunch/src/roslaunch/rlutil.py
--- a/tools/roslaunch/src/roslaunch/rlutil.py
+++ b/tools/roslaunch/src/roslaunch/rlutil.py
@@ -85,24 +85,26 @@ def resolve_launch_arguments(args):
     if not args:
         return args
     resolved_args = None
-    top = args[0]
-    if os.path.isfile(top):
-        resolved_args = [top] + args[1:]
-    elif len(args) == 1:
-        raise roslaunch.core.RLException("[%s] does not exist. please specify a package and launch file"%(top))
-    else:
+
+    # try to resolve launch file in package first
+    if len(args) >= 2:
         try:
-            resolved = roslib.packages.find_resource(top, args[1])
+            resolved = roslib.packages.find_resource(args[0], args[1])
+            if len(resolved) > 1:
+                raise roslaunch.core.RLException("multiple files named [%s] in package [%s]:%s\nPlease specify full path instead" % (args[1], args[0], ''.join(['\n- %s' % r for r in resolved])))
             if len(resolved) == 1:
-                resolved = resolved[0]
-            elif len(resolved) > 1:
-                raise roslaunch.core.RLException("multiple files named [%s] in package [%s]:%s\nPlease specify full path instead" % (args[1], top, ''.join(['\n- %s' % r for r in resolved])))
-        except rospkg.ResourceNotFound as e:
-            raise roslaunch.core.RLException("[%s] is not a package or launch file name"%top)
-        if not resolved:
-            raise roslaunch.core.RLException("cannot locate [%s] in package [%s]"%(args[1], top))
+                resolved_args = [resolved[0]] + args[2:]
+        except rospkg.ResourceNotFound:
+            pass
+    # try to resolve launch file
+    if resolved_args is None and os.path.isfile(args[0]):
+        resolved_args = [args[0]] + args[1:]
+    # raise if unable to resolve
+    if resolved_args is None:
+        if len(args) >= 2:
+            raise roslaunch.core.RLException("[%s] is neither a launch file in package [%s] nor is [%s] a launch file name" % (args[1], args[0], args[0]))
         else:
-            resolved_args = [resolved] + args[2:]
+            raise roslaunch.core.RLException("[%s] is not a launch file name" % args[0])
     return resolved_args
 
 def _wait_for_master():


Test patch: