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

Issue:
TreeTab not drawing menu correctly on multimonitor setups
### Issue description

I have a two monitor setup with different resolutions. 
One of my groups uses the TreeTab layout. Depending on which monitor it is first created on this layout has a gap in the menu region as you can see in this screenshot (the higher resolution monitor is on the left)
![2023-12-19_09-09](https://github.com/qtile/qtile/assets/1158010/8701c991-918c-40e7-b0d1-d305c1ba70b5)


### Version

0.23.0

### Backend

X11 (default)

### Config

_No response_

### Logs

_No response_

### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:
Sorry for the delay.

I know where the problem is. I'm just thinking about the best way to fix it!

Resolving patch:
diff --git a/libqtile/layout/tree.py b/libqtile/layout/tree.py
--- a/libqtile/layout/tree.py
+++ b/libqtile/layout/tree.py
@@ -733,6 +733,12 @@ def decrease_ratio(self):
         self.group.layout_all()
 
     def _create_drawer(self, screen_rect):
+        # Create a new drawer object if the screen is a different height
+        # e.g. if moving between screens with different resolutions
+        if self._drawer is not None and self._drawer.height != screen_rect.height:
+            self._drawer.finalize()
+            self._drawer = None
+
         if self._drawer is None:
             self._drawer = self._panel.create_drawer(
                 self.panel_width,


Test patch:
Repository: qtile/qtile

Issue:
Icons used in cloned LaunchBars do not dynamically change their size when `icon_size` isn't set
### Issue description

I cloned a LaunchBar for use on my multi-monitor setup, and drew bars for each monitor, with the main bar a different size from the secondary bars.

Resulting behavior: the icons on the secondary bar are sized appropriately, and the icons on the main bar match the size of the icons on the secondary bar.

Secondary bar:
![1706381680](https://github.com/qtile/qtile/assets/794101/7c7b2c65-344f-4493-b8a4-8fc31225c9ce)

Main bar (whose height is 2x the height of the secondary bar):
![1706381644](https://github.com/qtile/qtile/assets/794101/207e4480-1ad5-4904-be6b-c718527ae8b9)

Expected behavior: the size of the icons fit to the size of their respective bars.

Steps to reproduce:
1. Create a qtile environment with at least two available screens.
2. Create a LaunchBar widget that loads an image for the icon.  For example, a simple Discord launch button like `LB_test = widget.LaunchBar(progs=['discord', 'discord', ''])` should suffice.
3. Draw two bars in `screens` where one bar has a different size from the second one, and a clone of the above widget is inserted in place of the original.  For example, `screens = [Screen(bottom=bar.Bar([LB_test], 56)), Screen(bottom=bar.Bar([LB_test.clone()], 28))]`

If needed, I can include a version of my configuration file where the issue is produced.

### Version

0.23.0

### Backend

X11 (default)

### Logs

_No response_

### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:
Interesting. Will take a look.

Resolving patch:
diff --git a/libqtile/widget/base.py b/libqtile/widget/base.py
--- a/libqtile/widget/base.py
+++ b/libqtile/widget/base.py
@@ -400,7 +400,7 @@ def create_mirror(self):
         return Mirror(self, background=self.background)
 
     def clone(self):
-        return copy.copy(self)
+        return copy.deepcopy(self)
 
     def mouse_enter(self, x, y):
         pass


Test patch:
Repository: qtile/qtile

Issue:
lazy.spawn does not allow env variables with shell=True
### Issue description

A common shell syntax, to pass environment variables to processes is `GDK_DPI_SCALE=1 firefox`, i.e. putting it before the command to run. So it should also work when running it like this:

```python
lazy.spawn("GDK_DPI_SCALE=1 firefox", shell=True)
```

Instead qtile just logs:

> 2024-02-20 10:37:49,721 ERROR libqtile manager.py:spawn():L1255 couldn't find `GDK_DPI_SCALE=1`

The relevant code is here:
https://github.com/qtile/qtile/blob/afa4dcbff0c72452571465bf8258ea45510af959/libqtile/core/manager.py#L1255-L1261

It assumes that the first  part of the given string is a command name, but here it is the env setting.

Cf. discussion here: https://github.com/qtile/qtile/discussions/2794

### Version

0.24.0

### Backend

Wayland (experimental)

### Config

```python
EzKey("b", lazy.spawn("GDK_DPI_SCALE=1 firefox"), desc="Run firefox without scaling"),
```


### Logs

_No response_

### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:
Thanks. Yes, this is an issue caused by our code as we always assume the first item is the name of the command to run so we check if that's available.

I'll have a think at the best way to fix this.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -1225,7 +1225,9 @@ def validate_config(self) -> None:
             send_notification("Configuration check", "No error found!")
 
     @expose_command()
-    def spawn(self, cmd: str | list[str], shell: bool = False) -> int:
+    def spawn(
+        self, cmd: str | list[str], shell: bool = False, env: dict[str, str] = dict()
+    ) -> int:
         """
         Spawn a new process.
 
@@ -1236,6 +1238,8 @@ def spawn(self, cmd: str | list[str], shell: bool = False) -> int:
         shell:
             Whether to execute the command in a new shell by prepending it with "/bin/sh
             -c". This enables the use of shell syntax within the command (e.g. pipes).
+        env:
+            Dictionary of environmental variables to pass with command.
 
         Examples
         ========
@@ -1288,6 +1292,9 @@ def spawn(self, cmd: str | list[str], shell: bool = False) -> int:
                 except KeyError:
                     pass
 
+                for k, v in env.items():
+                    os.environ[k] = v
+
                 # Open /dev/null as stdin, stdout, stderr
                 try:
                     fd = os.open(os.devnull, os.O_RDWR)


Test patch:
Repository: qtile/qtile

Issue:
flaky tests do not report anything interesting
### Issue description

See e.g.:

https://github.com/qtile/qtile/actions/runs/8801434359/job/24154761197

reproduced here for posterity: https://gist.github.com/tych0/8653a01f34005c30b563e08fe0f10c0f

I have tried via c4d3c6e602f9ed619086cc3942bd1c47ebabedbf (and fixing it in 6f2c2ade8d4ad0283848249ce354d00a79b63791) to dump the stack and see where we're hanging in this case, but it seems to have not worked.

I am mostly filing this so I remember to keep working on it, but any other help is welcome. Flaky tests annoy me :)

### Version

git master

### Backend

X11 (default)

### Config

_No response_

### Logs

_No response_

### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -21,6 +21,7 @@
 from __future__ import annotations
 
 import asyncio
+import faulthandler
 import io
 import logging
 import os
@@ -213,6 +214,12 @@ async def async_loop(self) -> None:
         self.core.qtile = self
         self.load_config(initial=True)
         self.core.setup_listener()
+
+        faulthandler.enable(all_threads=True)
+        # This is a bit unfortunate. We use SIGUSR1&2 for reloading config &
+        # restarting qtile, so we overload SIGWINCH here to dump threads.
+        faulthandler.register(signal.SIGWINCH, all_threads=True)
+
         try:
             async with LoopContext(
                 {
diff --git a/libqtile/scripts/main.py b/libqtile/scripts/main.py
--- a/libqtile/scripts/main.py
+++ b/libqtile/scripts/main.py
@@ -1,7 +1,5 @@
 import argparse
-import faulthandler
 import logging
-import signal
 import sys
 from pathlib import Path
 
@@ -26,11 +24,6 @@ def check_folder(value):
 
 
 def main():
-    faulthandler.enable(all_threads=True)
-    # This is a bit unfortunate. We use SIGUSR1&2 for reloading config &
-    # restarting qtile, so we overload SIGWINCH here to dump threads.
-    faulthandler.register(signal.SIGWINCH, all_threads=True)
-
     parent_parser = argparse.ArgumentParser(add_help=False)
     parent_parser.add_argument(
         "-l",


Test patch:
Repository: Nitrate/Nitrate

Issue:
Drop Python 2.6 support



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,6 @@ def get_install_requires():
         'Intended Audience :: Developers',
         'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
         'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Topic :: Software Development :: Quality Assurance',
         'Topic :: Software Development :: Testing',
diff --git a/tcms/core/contrib/auth/__init__.py b/tcms/core/contrib/auth/__init__.py
--- a/tcms/core/contrib/auth/__init__.py
+++ b/tcms/core/contrib/auth/__init__.py
@@ -2,13 +2,7 @@
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
 from django.contrib.auth.models import Group
-
-# Python 2.7 has an importlib with import_module; for older Pythons,
-# Django's bundled copy provides it.
-try:
-    from importlib import import_module
-except ImportError:
-    from django.utils.importlib import import_module
+from importlib import import_module
 
 
 def get_backend(path):


Test patch:
Repository: Nitrate/Nitrate

Issue:
Installing files under /etc yields SandboxViolation in virtualenv
In one of my environments installing a newer version of Nitrate yields:
```
remote: error: Setup script exited with error: SandboxViolation: open('/etc/httpd/conf.d/nitrate-httpd.conf', 'wb') {}
```

this is due to the change made in ff4ecc75 adding the `data_files` attribute to `setup.py`. I propose installing these files under /etc via the RPM packages, not via pip. 


Discussion:
@tkdchen ping? This is a real problem in virtualenv or pretty much everywhere if you don't have root access. What's your take on it? 
Should be fixed. Removing relative code from ``setup.py`` should make it work well.
OK, sending a patch to fix `setup.py` shortly.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 
-import os
 from setuptools import setup, find_packages
 
 import tcms
@@ -20,6 +19,7 @@ def get_install_requires():
                 requires.append(dep_line)
         return requires, links
 
+
 install_requires, dependency_links = get_install_requires()
 
 
@@ -45,10 +45,6 @@ def get_long_description():
 
     packages=find_packages(),
     include_package_data=True,
-    data_files=[
-        ('/etc/httpd/conf.d/', ['contrib/conf/nitrate-httpd.conf']),
-        ('/etc/init.d', ['contrib/script/celeryd']),
-        ],
 
     classifiers=[
         'Intended Audience :: Developers',


Test patch:
Repository: Nitrate/Nitrate

Issue:
Should be status name rather than its id
After changing a test case run's status, log is `Field case_run_status changed from IDLE to 8.`, where 8 should be the status name rather than its id.



Discussion:
Relative to #11 


Resolving patch:
diff --git a/tcms/core/ajax.py b/tcms/core/ajax.py
--- a/tcms/core/ajax.py
+++ b/tcms/core/ajax.py
@@ -30,7 +30,7 @@
 from tcms.testcases.views import plan_from_request_or_none
 from tcms.testplans.models import TestPlan, TestCasePlan
 from tcms.testruns import signals as run_watchers
-from tcms.testruns.models import TestRun, TestCaseRun
+from tcms.testruns.models import TestRun, TestCaseRun, TestCaseRunStatus
 from tcms.core.exceptions import NitrateException
 from tcms.core.helpers.comments import add_comment
 from tcms.core.utils import get_string_combinations
@@ -521,8 +521,10 @@ def update_case_run_status(request):
             try:
                 t.log_action(
                     who=request.user,
-                    action='Field %s changed from %s to %s.' % (
-                        field, getattr(t, field), value
+                    action='Field {} changed from {} to {}.'.format(
+                        field,
+                        getattr(t, field),
+                        TestCaseRunStatus.id_to_string(value),
                     )
                 )
             except (AttributeError, User.DoesNotExist):


Test patch:
Repository: Nitrate/Nitrate

Issue:
Run with Django 1.11



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -48,6 +48,9 @@ def get_long_description():
     include_package_data=True,
 
     classifiers=[
+        'Framework :: Django',
+        'Framework :: Django :: 1.10',
+        'Framework :: Django :: 1.11',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
         'Programming Language :: Python :: 2',
diff --git a/tcms/core/utils/mailto.py b/tcms/core/utils/mailto.py
--- a/tcms/core/utils/mailto.py
+++ b/tcms/core/utils/mailto.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+
 import threading
 
 from celery import shared_task
@@ -6,7 +7,7 @@
 from django.conf import settings
 from django.core.mail import get_connection
 from django.core.mail import EmailMessage
-from django.template import loader, Context, RequestContext
+from django.template import loader
 
 
 @shared_task
@@ -23,9 +24,9 @@ def blocking_mailto(template_name, subject, to_mail, context=None,
     try:
         t = loader.get_template(template_name)
         if request:
-            mail_content = t.render(RequestContext(request, context))
+            mail_content = t.render(context=context, request=request)
         else:
-            mail_content = t.render(Context(context))
+            mail_content = t.render(context=context)
 
         connection = get_connection(username=None,
                                     password=None,
@@ -46,7 +47,7 @@ def non_blocking_mailto(template_name, subject, recipients=None,
                         context=None, sender=settings.EMAIL_FROM,
                         cc=None):
     t = loader.get_template(template_name)
-    body = t.render(Context(context))
+    body = t.render(context)
     if settings.DEBUG:
         recipients = settings.EMAILS_FOR_DEBUG
 
diff --git a/tcms/testcases/forms.py b/tcms/testcases/forms.py
--- a/tcms/testcases/forms.py
+++ b/tcms/testcases/forms.py
@@ -587,11 +587,12 @@ class CaseComponentForm(forms.Form):
     )
 
     def populate(self, product_id=None):
+        component_field = self.fields['o_component']
         if product_id:
-            self.fields['o_component'].queryset = Component.objects.filter(
-                product__id=product_id)
+            component_field.queryset = Component.objects.filter(
+                product__id=product_id).order_by('pk')
         else:
-            self.fields['o_component'].queryset = Component.objects.all()
+            component_field.queryset = Component.objects.order_by('pk')
 
 
 class CaseCategoryForm(forms.Form):


Test patch:
Repository: Nitrate/Nitrate

Issue:
django-preserialize requires django<1.11, Nitrate uses 1.11.11
Running through the required installation methods for Nitrate I run:
`sudo python setup.py install`

and I get 

`Processing dependencies for Nitrate==4.1
error: Django 1.11.11 is installed but django<1.11,>=1.8 is required by set(['django-preserialize'])`

The requirements.txt file shows:
`Django=1.11.11
...
django-preserialize==1.2.1`

Should I change the Django version down to 1.10.xx?


Discussion:
I think you should uninstall Django 1.11.11, or create a python virtualenv to install django 1.8 for nitrate 4.1

You can also try https://demo.kiwitcms.org which is running latest Django 2
@nugatorium Yes, you can change to use Django 1.10.x.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,6 @@ def get_long_description():
     'beautifulsoup4 >= 4.1.1',
     'celery == 4.1.0',
     'django-contrib-comments == 1.8.0',
-    'django-preserialize == 1.2.1',
     'django-tinymce == 2.6.0',
     'django-uuslug == 1.1.8',
     'django >= 1.10,<2.0',
diff --git a/tcms/testplans/views.py b/tcms/testplans/views.py
--- a/tcms/testplans/views.py
+++ b/tcms/testplans/views.py
@@ -22,7 +22,6 @@
 from django.views.decorators.http import require_GET
 from django.views.decorators.http import require_http_methods
 from django.views.generic import View
-from preserialize.serialize import serialize
 from uuslug import slugify
 
 from tcms.core.db import SQLExecution
@@ -254,12 +253,20 @@ def all(request, template_name='plan/all.html'):
         tps = tps.order_by('name')
 
     if request.GET.get('t') == 'ajax':
-        return JsonResponse(
-            serialize(tps, fields=[
-                'pk', 'name', 'is_active', 'parent_id',
-                'num_cases', 'num_runs', 'num_children', 'get_url_path'
-            ]),
-            safe=False)
+        data = [
+            dict(
+                pk=plan.pk,
+                name=plan.name,
+                is_active=plan.is_active,
+                parent_id=plan.parent_id,
+                num_cases=plan.num_cases,
+                num_runs=plan.num_runs,
+                num_children=plan.num_children,
+                get_url_path=plan.get_absolute_url(),
+            )
+            for plan in tps
+        ]
+        return JsonResponse(data, safe=False)
 
     if request.GET.get('t') == 'html':
         if request.GET.get('f') == 'preview':


Test patch:
Repository: Nitrate/Nitrate

Issue:
Remove Piwik 
It is not used any more.


Discussion:

Resolving patch:
diff --git a/tcms/settings/common.py b/tcms/settings/common.py
--- a/tcms/settings/common.py
+++ b/tcms/settings/common.py
@@ -361,15 +361,6 @@
 # .py and make sure qpid config is correct.
 ENABLE_QPID = False
 
-# TCMS use Piwik to track request.
-ENABLE_PIWIK_TRACKING = False
-# Piwik site id, generate by eng-ops
-PIWIK_SITE_ID = ''
-# Piwik api url without schema.
-PIWIK_SITE_API_URL = ''
-# Piwik js lib url without schema
-PIWIK_SITE_JS_URL = ''
-
 # A sample logging configuration. The only tangible logging
 # performed by this configuration is to send an email to
 # the site admins on every HTTP 500 error when DEBUG=False.


Test patch:
Repository: Nitrate/Nitrate

Issue:
Upgrade django-tinymce to 2.7.0
As per subject.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ def get_long_description():
     'beautifulsoup4 >= 4.1.1',
     'celery == 4.1.0',
     'django-contrib-comments == 1.8.0',
-    'django-tinymce == 2.6.0',
+    'django-tinymce == 2.7.0',
     'django-uuslug == 1.1.8',
     'django >= 1.10,<2.0',
     'html2text',


Test patch:
Repository: Nitrate/Nitrate

Issue:
Remove django 1.10 support
- Remove django 1.10 testenv from tox.ini
- Update django version in setup.py. Minimum django version is `1.11`.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ def get_long_description():
     'PyMySQL == 0.7.11',
     'beautifulsoup4 >= 4.1.1',
     'celery == 4.1.0',
-    'django >= 1.10,<2.0',
+    'django >= 1.11,<2.0',
     'django-contrib-comments == 1.8.0',
     'django-tinymce == 2.7.0',
     'django-uuslug == 1.1.8',
@@ -86,7 +86,6 @@ def get_long_description():
     include_package_data=True,
     classifiers=[
         'Framework :: Django',
-        'Framework :: Django :: 1.10',
         'Framework :: Django :: 1.11',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',


Test patch:
Repository: Nitrate/Nitrate

Issue:
Ensure to work with Python 3.7



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -97,6 +97,7 @@ def get_long_description():
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
         'Topic :: Software Development :: Quality Assurance',
         'Topic :: Software Development :: Testing',
     ],


Test patch:
diff --git a/tcms/core/tests/test_core.py b/tcms/core/tests/test_core.py
--- a/tcms/core/tests/test_core.py
+++ b/tcms/core/tests/test_core.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
+import sys
 import unittest
 from mock import patch
 from mock import Mock
@@ -15,6 +16,8 @@
 from tcms.core.task import AsyncTask
 from tcms.core.task import Task
 
+PY37 = sys.version_info[:2] == (3, 7)
+
 
 class TestUtilsFunctions(unittest.TestCase):
 
@@ -292,6 +295,8 @@ def test_uses_threading(self, Thread):
             self.assertTrue(thread.daemon)
             thread.start.assert_called_once()
 
+    @unittest.skipIf(PY37, 'Celery<4.3 does not work with Python 3.7. '
+                           'Waiting for 4.3 to be released.')
     @patch('celery.shared_task')
     def test_uses_celery(self, shared_task):
         with patch.object(settings, 'ASYNC_TASK', new=AsyncTask.CELERY.value):
Repository: Nitrate/Nitrate

Issue:
Add more information links to package
Add these links to `project_urls` argument of `setup.py`.

- Source Code: https://github.com/Nitrate/Nitrate
- Issue Tracker: https://github.com/Nitrate/Nitrate/issues
- Documentation: https://nitrate.readthedocs.io/


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -105,4 +105,9 @@ def get_long_description():
         'Topic :: Software Development :: Quality Assurance',
         'Topic :: Software Development :: Testing',
     ],
+    project_urls={
+        'Issue Tracker': 'https://github.com/Nitrate/Nitrate/issues',
+        'Source Code': 'https://github.com/Nitrate/Nitrate',
+        'Documentation': 'https://nitrate.readthedocs.io/',
+    },
 )


Test patch:
Repository: Nitrate/Nitrate

Issue:
Mark Nitrate as not zip_safe
Add `zip_safe=False` to `setup.py` because Nitrate cannot run from a zip file directly.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,7 @@ def get_long_description():
     extras_require=extras_require,
     packages=find_packages(),
     include_package_data=True,
+    zip_safe=False,
     classifiers=[
         'Framework :: Django',
         'Framework :: Django :: 1.11',


Test patch: