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

Issue:
admin interface error ticket reading issue, missing second 'r' parameter in safe_open() 
https://github.com/web2py/web2py/blob/70bd81412ec9ad2387f1386e402b37ce6b57b4ad/applications/admin/controllers/default.py#L1731


Discussion:

Resolving patch:
diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py
--- a/applications/admin/controllers/default.py
+++ b/applications/admin/controllers/default.py
@@ -1728,7 +1728,7 @@ def get_ticket_storage(app):
     private_folder = apath('%s/private' % app, r=request)
     ticket_file = os.path.join(private_folder, 'ticket_storage.txt')
     if os.path.exists(ticket_file):
-        db_string = safe_open(ticket_file).read()
+        db_string = safe_read(ticket_file)
         db_string = db_string.strip().replace('\r', '').replace('\n', '')
     elif is_gae:
         # use Datastore as fallback if there is no ticket_file
diff --git a/applications/admin/languages/pt.py b/applications/admin/languages/pt.py
--- a/applications/admin/languages/pt.py
+++ b/applications/admin/languages/pt.py
@@ -385,6 +385,7 @@
 'no match': 'não encontrado',
 'no package selected': 'nenhum pacote selecionado',
 'no permission to uninstall "%s"': 'no permission to uninstall "%s"',
+'No ticket_storage.txt found under /private folder': 'Não foi encontrado um ficheiro ticket_storage.txt na diretoria /private',
 'Node:': 'Node:',
 'Not Authorized': 'Not Authorized',
 'Not supported': 'Not supported',


Test patch:
Repository: web2py/web2py

Issue:
Missing "reload" in the compatibility import list
I'm using web2py ver. 2.22.1 with Python 3.9.9. Generally speaking, no special problems.
There's am error message which has been there for some time now, when using Modules. When I save the module in the built-in editor, it gives an error message, saying that "reload" is not found.

After short digging I think I discovered that indeed "reload" is missing from the compatibility imports in line 18 of default.py (applications/admin/controller/default.py), as it is later used in line 778. This is due to "reload" being handled differently in different versions of Python.

Please correct me if I'm wrong or help to fix this in the official package.


Discussion:

Resolving patch:
diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py
--- a/applications/admin/controllers/default.py
+++ b/applications/admin/controllers/default.py
@@ -15,7 +15,7 @@
 from gluon.tools import Config
 from gluon.compileapp import find_exposed_functions
 from glob import glob
-from gluon._compat import iteritems, PY2, pickle, xrange, urlopen, to_bytes, StringIO, to_native
+from gluon._compat import iteritems, PY2, pickle, xrange, urlopen, to_bytes, StringIO, to_native, reload
 import gluon.rewrite
 import shutil
 import platform


Test patch:
Repository: web2py/web2py

Issue:
web2py 2.23.0 is giving a 403 error when I try to package my applications
**Describe the bug**
When I try to pack the welcome application (or any other), using pack_all I get a 403 error.

**To Reproduce**
Steps to reproduce the behavior:
1. Install fresh we2py and start the web2py server
2. Go to the admin/default/site
3. Click on Welcome: Manage > Pack All
4. Immediately get a "403 FORBIDDEN" page

**Expected behavior**
Should get dialog asking where to download the application package file.

**Screenshots**


**Desktop (please complete the following information):**
 - OS: Windows 10
 - Chrome
 - Version: 2.23.0-stable+timestamp.2022.12.26.23.06.56 (Running on Rocket 1.2.6, Python 3.8.10)

**Additional context**
Additional investigation by "Davidiam" in web2py google group. https://groups.google.com/g/web2py/c/buq0kJf2d_U



Discussion:

Resolving patch:
diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py
--- a/applications/admin/controllers/default.py
+++ b/applications/admin/controllers/default.py
@@ -85,8 +85,12 @@ def close(self):
         return tmp()
 
     a_for_check = os.path.abspath(os.path.normpath(a))
+    
     web2py_apps_root = os.path.abspath(up(request.folder))
-    if not a_for_check.startswith(web2py_apps_root):
+    web2py_deposit_root = os.path.join(up(web2py_apps_root), 'deposit')
+
+    if not (a_for_check.startswith(web2py_apps_root) or
+        a_for_check.startswith(web2py_deposit_root)):
         raise HTTP(403)
 
     if PY2 or 'b' in b:


Test patch:
Repository: web2py/web2py

Issue:
scheduler.py AttributeError: '_thread._local' object has no attribute '_scheduler'
When the scheduler is run with use_spawn=True, it fails to pickup tasks whose functions are defined in a different app that the one from where the scheduler was run:

`Traceback (most recent call last): File "/home/limon/medios/gluon/scheduler.py", line 494, in executor functions = current._scheduler.tasks AttributeError: '_thread._local' object has no attribute '_scheduler'`


**Steps to reproduce**

1. Create three web2py applications: main, app1 and app2.
2. Define the scheduler in the main application with Scheduler(..., use_spawn=True)
3. Run a scheduler worker for main application with "web2py.py -K main"
4. Queue three tasks, defining each of them in a different application.
5. You will see that the task defined in "main" application runs ok, but the others fail.

I'm running web2py Version 2.24.1-stable+timestamp.2023.03.23.05.07.17 on python 3.9.14, Rocky Linux RHEL9.
I'll propose a fix.


Discussion:

Resolving patch:
diff --git a/gluon/scheduler.py b/gluon/scheduler.py
--- a/gluon/scheduler.py
+++ b/gluon/scheduler.py
@@ -488,7 +488,10 @@ def write(self, data):
                        extra_request={'is_scheduler': True})
             #logging.getLogger().setLevel(level)
             f = task.function
-            functions = current._scheduler.tasks
+            if hasattr(current, '_scheduler') and hasattr(current._scheduler, 'tasks'):
+                functions = current._scheduler.tasks
+            else:
+                functions = None
             if functions:
                 _function = functions.get(f)
             else:


Test patch:
Repository: open-mmlab/mmdeploy

Issue:
pytorch2onnx fails with mmedit models
error with master branch
```
TypeError: forward_dummy() got an unexpected keyword argument 'img_metas'
```


Discussion:

Resolving patch:
diff --git a/mmdeploy/apis/pytorch2onnx.py b/mmdeploy/apis/pytorch2onnx.py
--- a/mmdeploy/apis/pytorch2onnx.py
+++ b/mmdeploy/apis/pytorch2onnx.py
@@ -61,7 +61,11 @@ def torch2onnx(img: Any,
 
     torch_model = task_processor.init_pytorch_model(model_checkpoint)
     data, model_inputs = task_processor.create_input(img, input_shape)
-    input_metas = dict(img_metas=data.get('img_metas', None))
+    if 'img_metas' in data:
+        input_metas = dict(img_metas=data['img_metas'])
+    else:
+        # codebases like mmedit do not have img_metas argument
+        input_metas = None
     if not isinstance(model_inputs, torch.Tensor) and len(model_inputs) == 1:
         model_inputs = model_inputs[0]
 


Test patch:
Repository: open-mmlab/mmdeploy

Issue:
[Feature] wrap libtorch as net module in MMDeploy SDK
**Describe the feature**
As described in the title, this feature requests developing NetModule by wrapping libtorch in MMDeploy SDK.
Therefore, we can do torchscript model  inference via SDK API

**Motivation**
#345

**Related resources**

**Additional context**
Add any other context or screenshots about the feature request here.
If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated.



Discussion:
Hi @lvhan028 , I want to pick this one 😄 
Great. Thank you so much ^^
Hi @lvhan028 
Sorry, I am temporarily unable to complete my contribution due to my working stuff. Please assign it to others.
I'm very sorry. 😭 

I will continue to make contributions to MMDeploy when my work is relatively idle. 😄 

Resolving patch:
diff --git a/mmdeploy/backend/sdk/export_info.py b/mmdeploy/backend/sdk/export_info.py
--- a/mmdeploy/backend/sdk/export_info.py
+++ b/mmdeploy/backend/sdk/export_info.py
@@ -167,16 +167,25 @@ def get_inference_info(deploy_cfg: mmcv.Config, model_cfg: mmcv.Config,
     input = ['prep_output']
     output = ['infer_output']
     ir_config = get_ir_config(deploy_cfg)
-    input_names = ir_config.get('input_names', None)
-    input_name = input_names[0] if input_names else 'input'
-    input_map = dict(img=input_name)
+
+    backend = get_backend(deploy_cfg=deploy_cfg)
+    if backend == Backend.TORCHSCRIPT:
+        output_names = ir_config.get('output_names', None)
+        input_map = dict(img='#0')
+        output_map = {name: f'#{i}' for i, name in enumerate(output_names)}
+    else:
+        input_names = ir_config.get('input_names', None)
+        input_name = input_names[0] if input_names else 'input'
+        input_map = dict(img=input_name)
+        output_map = {}
     return_dict = dict(
         name=name,
         type=type,
         module=module,
         input=input,
         output=output,
-        input_map=input_map)
+        input_map=input_map,
+        output_map=output_map)
     if 'use_vulkan' in deploy_cfg['backend_config']:
         return_dict['use_vulkan'] = deploy_cfg['backend_config']['use_vulkan']
     return return_dict


Test patch:
Repository: lutris/lutris

Issue:
register account menu option: play nice with KDE/Plasma :-)
I'm running Gentoo with Plasma 5... Just poking about with Lutris (first install today).

Full disclaimer: I'm no Python developer... But would it not be cleaner to use:

```
lutriswindow.py

    def on_register_account(self, *args):
        subprocess.call(('xdg-open', "http://lutris.net/user/register"))
```

Which opens the register link in my default desktop browser (**Firefox**)... Clean. oui, oui, **oui** :-)

Currently, on my Plasma 5 setup, by default the **Register account** menu option opens a large X-version of the **links** browser... Uhmmm... shakes head... non, non, **non** :-(

Just a thought.

Thanks for such an interesting tool!!



Discussion:

Resolving patch:
diff --git a/lutris/gui/lutriswindow.py b/lutris/gui/lutriswindow.py
--- a/lutris/gui/lutriswindow.py
+++ b/lutris/gui/lutriswindow.py
@@ -2,6 +2,7 @@
 # pylint: disable=E0611
 import os
 import time
+import subprocess
 
 from gi.repository import Gtk, Gdk, GLib
 
@@ -386,7 +387,10 @@ def toggle_connection(self, is_connected, username=None):
         connection_label.set_text(connection_status)
 
     def on_register_account(self, *args):
-        Gtk.show_uri(None, "http://lutris.net/user/register", Gdk.CURRENT_TIME)
+        try:
+            subprocess.check_call(["xdg-open", "https://lutris.net/user/register"])
+        except CalledProcessError:
+            Gtk.show_uri(None, "https://lutris.net/user/register", Gdk.CURRENT_TIME)
 
     def on_synchronize_manually(self, *args):
         """Callback when Synchronize Library is activated."""


Test patch:
Repository: lutris/lutris

Issue:
[WINE Runner] --> run exe
It should be possible to run an EXE/MSI in this winebottle/gamedir to install a patch, update or language fix(eg add it to the right click menu)



Discussion:

Resolving patch:
diff --git a/lutris/runners/wine.py b/lutris/runners/wine.py
--- a/lutris/runners/wine.py
+++ b/lutris/runners/wine.py
@@ -11,6 +11,7 @@
 from lutris.util.strings import version_sort
 from lutris.runners.runner import Runner
 from lutris.thread import LutrisThread
+from lutris.gui.dialogs import FileDialog
 
 WINE_DIR = os.path.join(settings.RUNNER_DIR, "wine")
 WINE_PATHS = {
@@ -369,6 +370,7 @@ class wine(Runner):
     def __init__(self, config=None):
         super(wine, self).__init__(config)
         self.context_menu_entries = [
+            ('wineexec', "Run EXE inside wine prefix", self.run_wineexec),
             ('winecfg', "Wine configuration", self.run_winecfg),
             ('wine-regedit', "Wine registry", self.run_regedit),
             ('winetricks', 'Winetricks', self.run_winetricks),
@@ -621,6 +623,13 @@ def msi_exec(cls, msi_file, quiet=False, prefix=None, wine_path=None, working_di
         return wineexec("msiexec", args=msi_args, prefix=prefix,
                         wine_path=wine_path, working_dir=working_dir, blocking=blocking)
 
+    def run_wineexec(self, *args):
+        dlg = FileDialog("Select an EXE or MSI file")
+        filename = dlg.filename
+        if not filename:
+            return
+        wineexec(filename, wine_path=self.get_executable(), prefix=self.prefix_path)
+
     def run_winecfg(self, *args):
         winecfg(wine_path=self.get_executable(), prefix=self.prefix_path,
                 arch=self.wine_arch, blocking=False)


Test patch:
Repository: lutris/lutris

Issue:
Create desktop/application menu shortcut writes a bad .desktop file
File contents:

```
[Desktop Entry]
Type=Application
Name=%s
Icon=%s
Exec=lutris lutris:%s
Categories=Game
```

**How to reproduce**
Right click a game and select Create desktop shortcut.
Navigate to ~/Desktop
You see a file with name `gameslug-id.desktop` but it contains what's above. If you're in a file manager you see the game title instead of the filename, so it appears as `%s` there.

**Lutris debug output**

```
[system]:Executing which xdg-user-dir
```

Operating system: Arch Linux



Discussion:

Resolving patch:
diff --git a/lutris/shortcuts.py b/lutris/shortcuts.py
--- a/lutris/shortcuts.py
+++ b/lutris/shortcuts.py
@@ -30,9 +30,9 @@ def create_launcher(game_slug, game_id, game_name, desktop=False, menu=False):
         """
         [Desktop Entry]
         Type=Application
-        Name=%s
-        Icon=%s
-        Exec=lutris lutris:%s
+        Name={}
+        Icon={}
+        Exec=lutris lutris:{}
         Categories=Game
         """.format(game_name, 'lutris_{}'.format(game_slug), game_id)
     )


Test patch:
Repository: lutris/lutris

Issue:
Running game changes to default X cursor in main window
![cursor](https://i.imgbox.com/uyN4gDZq.png)

I think [this is the code](https://github.com/lutris/lutris/blob/cbe6f5d5d982543a66f95aa62f0d8e26dd462470/lutris/util/display.py#L10) that sets the cursor. This was introduced in the commit https://github.com/lutris/lutris/commit/4bb2d78e5c3626057f9dc10dcc27f74ae67853b9

Right now it's using [GdkCursorType](https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html#GdkCursorType) to set cursor, but it seems like we should be using [gdk_cursor_new_from_name()](https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html#gdk-cursor-new-from-name) instead which is the recommended way.



Discussion:

Resolving patch:
diff --git a/lutris/util/display.py b/lutris/util/display.py
--- a/lutris/util/display.py
+++ b/lutris/util/display.py
@@ -6,14 +6,10 @@
 
 def set_cursor(name, window, display=None):
     """Set a named mouse cursor for the given window."""
-    cursors = {
-        'default': Gdk.CursorType.ARROW,
-        'wait': Gdk.CursorType.WATCH,
-    }
 
     if not display:
         display = Gdk.Display.get_default()
-    cursor = Gdk.Cursor.new_for_display(display, cursors[name])
+    cursor = Gdk.Cursor.new_from_name(display, name)
     window.set_cursor(cursor)
 
 


Test patch:
Repository: lutris/lutris

Issue:
Specify a User Agent for HTTP requests
Right now it's python-urllib/someversion, and Cloudflare sites (tested on medium protection site) blocks it and returns 403 status code.
Testing the same url with curl works without it blocking, so I'm guessing Cloudflare checks the request UA.


Discussion:
The installer download for AutoHotkey is also blocked for Lutris, gives 403. I haven't checked if they use Cloudflare, but I guess they do.
https://autohotkey.com/download/

Resolving patch:
diff --git a/lutris/util/http.py b/lutris/util/http.py
--- a/lutris/util/http.py
+++ b/lutris/util/http.py
@@ -5,6 +5,8 @@
 import urllib.parse
 from ssl import CertificateError
 
+from lutris.settings import PROJECT
+from lutris.settings import VERSION
 from lutris.settings import SITE_URL
 from lutris.util.log import logger
 
@@ -29,6 +31,8 @@ def __init__(self, url, timeout=5, stop_request=None,
         self.thread_queue = thread_queue
         self.buffer_size = 32 * 1024  # Bytes
         self.downloaded_size = 0
+        if not headers.get('User-Agent'):
+            headers['User-Agent'] = PROJECT + '/' + VERSION
         self.headers = headers
 
     def get(self, data=None):


Test patch:
Repository: lutris/lutris

Issue:
Lutris 0.4.5 doesn’t launch (AssertionError)
I'm using Linux Mint 18.1 (my de is Mate if that's any help) and I received the update for Lutris 0.4.5. I tried to launch Lutris after that and nothing seemed to happen. I then tried to launch it from the terminal with the command "lutris" and saw the following:

```python
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/lutris/gui/application.py", line 152, in do_activate
self.window = LutrisWindow(application=self)
File "/usr/lib/python3/dist-packages/lutris/gui/lutriswindow.py", line 84, in init
desktopapps.sync_with_lutris()
File "/usr/lib/python3/dist-packages/lutris/util/desktopapps.py", line 87, in sync_with_lutris
mark_as_installed(appid, 'linux', game_info)
File "/usr/lib/python3/dist-packages/lutris/util/desktopapps.py", line 32, in mark_as_installed
assert game_info[key]
AssertionError
```

I do hope you fix it, as I run quite a few dosbox/scummvm games, and a Wine game with it, so I kind of need it for gaming. Thanks for the understanding.
P.S. I had also posted it on the forum, but overcame my reluctance to not creating many accounts online, as it's kind of important that this gets resolved.


Discussion:
I'll have a look at this as soon as I can, thanks for reporting it! :)

Resolving patch:
diff --git a/lutris/util/desktopapps.py b/lutris/util/desktopapps.py
--- a/lutris/util/desktopapps.py
+++ b/lutris/util/desktopapps.py
@@ -18,6 +18,7 @@
     "fs-uae-arcade", "PCSX2", "ppsspp", "qchdman", "qmc2-sdlmame", "qmc2-arcade",
     "sc-controller", "epsxe"
 )
+
 IGNORED_EXECUTABLES = (
     "lutris", "steam"
 )
@@ -41,12 +42,19 @@ def mark_as_installed(appid, runner_name, game_info):
         installer_slug=game_info['installer_slug']
     )
 
-    game_config = LutrisConfig(
+    config = LutrisConfig(
         runner_slug=runner_name,
         game_config_id=config_id,
     )
-    game_config.raw_game_config.update({'appid': appid, 'exe': game_info['exe'], 'args': game_info['args']})
-    game_config.save()
+    config.raw_game_config.update({
+        'appid': appid,
+        'exe': game_info['exe'],
+        'args': game_info['args']
+    })
+    config.raw_system_config.update({
+        'disable_runtime': True
+    })
+    config.save()
     return game_id
 
 
@@ -71,8 +79,23 @@ def sync_with_lutris():
     for app in apps:
         game_info = None
         name = app[0]
-        slug = slugify(name)
         appid = app[1]
+        slug = slugify(name)
+
+        # if it fails to get slug from the name
+        if not slug:
+            slug = slugify(appid)
+
+        if not name or not slug or not appid:
+            logger.error("Failed to load desktop game "
+                         "\"" + str(name) + "\" "
+                         "(app: " + str(appid) + ", slug: " + slug + ")")
+            continue
+        else:
+            logger.debug("Found desktop game "
+                         "\"" + str(name) + "\" "
+                         "(app: " + str(appid) + ", slug: " + slug + ")")
+
         seen_slugs.add(slug)
 
         if slug not in slugs_in_lutris:


Test patch:
Repository: lutris/lutris

Issue:
Lutris shortcuts broken
See: https://forums.lutris.net/t/desktop-shortcut-not-work-for-any-game/456


Discussion:

Resolving patch:
diff --git a/lutris/util/resources.py b/lutris/util/resources.py
--- a/lutris/util/resources.py
+++ b/lutris/util/resources.py
@@ -107,6 +107,8 @@ def parse_installer_url(url):
     game_slug = parsed_url.path
     if not game_slug:
         return False
+    if game_slug.startswith('lutris:'):
+        game_slug = game_slug[7:]
     revision = None
     if parsed_url.query:
         query = dict(parse_qsl(parsed_url.query))


Test patch:
Repository: lutris/lutris

Issue:
Issue with folder paths containing parenthesis
The default warframe install path is C:\Program Files (x86)\Warframe. The install script and lutris itself after trying to launch the .bat file give me this error when using the (x86) path:

Can't recognise '/home/gloriouseggroll/Games/warframe/drive_c/Program Files (x86)/Warframe/Warframe-Launcher.bat' as an internal or external command, or batch script

It works properly if installed to 
C:\Program Files\Warframe


Discussion:

Resolving patch:
diff --git a/lutris/runners/wine.py b/lutris/runners/wine.py
--- a/lutris/runners/wine.py
+++ b/lutris/runners/wine.py
@@ -165,7 +165,7 @@ def wineexec(executable, args="", wine_path=None, prefix=None, arch=None,
         if os.path.isfile(executable):
             working_dir = os.path.dirname(executable)
 
-    executable, _args = get_real_executable(executable)
+    executable, _args, working_dir = get_real_executable(executable, working_dir)
     if _args:
         args = '{} "{}"'.format(_args[0], _args[1])
 
@@ -358,21 +358,25 @@ def support_legacy_version(version):
     return version
 
 
-def get_real_executable(windows_executable):
+def get_real_executable(windows_executable, working_dir=None):
     """Given a Windows executable, return the real program
     capable of launching it along with necessary arguments."""
+
     exec_name = windows_executable.lower()
 
     if exec_name.endswith(".msi"):
-        return ('msiexec', ['/i', windows_executable])
+        return ('msiexec', ['/i', windows_executable], working_dir)
 
     if exec_name.endswith(".bat"):
-        return ('cmd', ['/C', windows_executable])
+        if not working_dir or os.path.dirname(windows_executable) == working_dir:
+            working_dir = os.path.dirname(windows_executable) or None
+            windows_executable = os.path.basename(windows_executable)
+        return ('cmd', ['/C', windows_executable], working_dir)
 
     if exec_name.endswith(".lnk"):
-        return ('start', ['/unix', windows_executable])
+        return ('start', ['/unix', windows_executable], working_dir)
 
-    return (windows_executable, [])
+    return (windows_executable, [], working_dir)
 
 
 # pylint: disable=C0103
@@ -891,7 +895,8 @@ def play(self):
             self.setup_x360ce(self.runner_config['x360ce-path'])
 
         command = [self.get_executable()]
-        game_exe, _args = get_real_executable(game_exe)
+
+        game_exe, _args, working_dir = get_real_executable(game_exe, self.working_dir)
         command.append(game_exe)
         if _args:
             command = command + _args


Test patch:
Repository: lutris/lutris

Issue:
Linux installer fails with `- steam-data: $WINESTEAM:<game-id>:/` in files section
Example installer https://lutris.net/games/install/6274/view or https://lutris.net/games/install/1783/view
@strycore 


Discussion:

Resolving patch:
diff --git a/lutris/installer/interpreter.py b/lutris/installer/interpreter.py
--- a/lutris/installer/interpreter.py
+++ b/lutris/installer/interpreter.py
@@ -257,14 +257,14 @@ def _download_file(self, game_file):
         else:
             file_uri = game_file[file_id]
             filename = os.path.basename(file_uri)
-        if not filename:
-            raise ScriptingError("No filename provided, please provide 'url' and 'filename' parameters in the script")
         if file_uri.startswith("/"):
             file_uri = "file://" + file_uri
         elif file_uri.startswith(("$WINESTEAM", "$STEAM")):
             # Download Steam data
             self._download_steam_data(file_uri, file_id)
             return
+        if not filename:
+            raise ScriptingError("No filename provided, please provide 'url' and 'filename' parameters in the script")
 
         # Check for file availability in PGA
         pga_uri = pga.check_for_file(self.game_slug, file_id)


Test patch: