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

Issue:
Unused variable in carousel (bad/missing renaming)
During the pyconfr2018 sprint, one user found this:

https://github.com/kivy/kivy/blob/d73a138f0a952ee4b632f756a61fcab696a56bc4/kivy/uix/carousel.py#L538

Seems like the variable got un-camelcase, but some are missing.


Discussion:

Resolving patch:
diff --git a/kivy/uix/carousel.py b/kivy/uix/carousel.py
--- a/kivy/uix/carousel.py
+++ b/kivy/uix/carousel.py
@@ -529,13 +529,13 @@ def on_touch_move(self, touch):
                 if abs(touch.oy - touch.y) < self.scroll_distance:
                     if abs(touch.ox - touch.x) > self.scroll_distance:
                         self._change_touch_mode()
-                        self.touchModeChange = True
+                        self.touch_mode_change = True
             elif self.ignore_perpendicular_swipes and \
                     self.direction in ('right', 'left'):
                 if abs(touch.ox - touch.x) < self.scroll_distance:
                     if abs(touch.oy - touch.y) > self.scroll_distance:
                         self._change_touch_mode()
-                        self.touchModeChange = True
+                        self.touch_mode_change = True
 
         if self._get_uid('cavoid') in touch.ud:
             return


Test patch:
Repository: kivy/kivy

Issue:
Rotating Scatter does not dispatch on_transform_with_touch
### Versions

* Python 3.6.1 + Kivy 1.10 on Windows
* Python 3.6.4 + recent master on Linux

### Description

1. Rotating Scatter does not dispatch the on_transform_with_touch event

2. Translating Scatter with `do_translation=False` still dispatches the on_transform_with_touch event

### Code and Logs

```python
from kivy.base import runTouchApp
from kivy.lang import Builder

runTouchApp(Builder.load_string('''
Scatter:
    size_hint: None, None
    pos: 200, 200
    do_scale: False
    do_translation: False
    on_transform_with_touch: print("!!! Transform")

    canvas:
        Color:
            rgba: 1, 0, 0, 1
        Rectangle:
            pos: 0, 0
            size: self.size
'''))
```



Discussion:

Resolving patch:
diff --git a/kivy/uix/scatter.py b/kivy/uix/scatter.py
--- a/kivy/uix/scatter.py
+++ b/kivy/uix/scatter.py
@@ -476,6 +476,8 @@ def transform_with_touch(self, touch):
             return changed
 
         angle = radians(new_line.angle(old_line)) * self.do_rotation
+        if angle:
+            changed = True
         self.apply_transform(Matrix().rotate(angle, 0, 0, 1), anchor=anchor)
 
         if self.do_scale:


Test patch:
Repository: kivy/kivy

Issue:
🙏 emoji in README.md breaks return fileh.read() in pip install from master
When running with latest pip 19
```
pip3 install https://github.com/kivy/kivy/archive/master.zip
```

I get:
```
Collecting https://github.com/kivy/kivy/archive/master.zip
  Downloading https://github.com/kivy/kivy/archive/master.zip
     / 41.6MB 24.9MB/s
    Complete output from command python setup.py egg_info:
    fatal: not a git repository (or any of the parent directories): .git
     Traceback (most recent call last):
       File "<string>", line 1, in <module>
       File "/tmp/pip-req-build-qbahrg18/setup.py", line 1007, in <module>
         long_description=get_description(),
       File "/tmp/pip-req-build-qbahrg18/setup.py", line 44, in get_description
         return fileh.read()
       File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
         return codecs.ascii_decode(input, self.errors)[0]
     UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 4973: ordinal not in range(128)
    Using distutil
```

position 4973 is the 🙏 emoji


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -40,8 +40,8 @@ def ver_equal(self, other):
 
 
 def get_description():
-    with open(join(dirname(__file__), 'README.md')) as fileh:
-        return fileh.read()
+    with open(join(dirname(__file__), 'README.md'), 'rb') as fileh:
+        return fileh.read().decode("utf8")
 
 
 def get_version(filename='kivy/version.py'):


Test patch:
Repository: kivy/kivy

Issue:
Segfault in core image when loading same image twice
### Versions

* Python: 3.6.7
* OS: Ubuntu 18.10
* Kivy:  v1.10.1
* Kivy installation method: PIP I presume, I tried via github but build was broken at the time

### Description

Running the image constructor on the same image twice core-dumps with a segfault.

### Code and Logs


Requires image magick:
```bash
convert -size 800x800 xc:white white.png
python3 -c 'from kivy.core.image import Image; Image("white.png"); Image("white.png")'
rm white.png
```
Output
```python
[INFO   ] [Logger      ] Record log in /home/jonny/.kivy/logs/kivy_19-02-25_46.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0]
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[1]    28864 segmentation fault (core dumped)  python3 -c 
```



Discussion:
If it segfault, then it's because it's requiring OpenGL, which is not initialized in your test.

This works:
```
python3 -c 'import kivy.core.window; from kivy.core.image import Image; Image("white.png"); Image("white.png")'
```

But we should have a catch about that yes.

Without knowing the internals, it seems to me that if Image is requiring OpenGL, and importing kivy.core.window is how you fix it, then Image needs to be the one importing OpenGL as that is a dependancy of core Image

Resolving patch:
diff --git a/kivy/core/image/__init__.py b/kivy/core/image/__init__.py
--- a/kivy/core/image/__init__.py
+++ b/kivy/core/image/__init__.py
@@ -741,7 +741,6 @@ def _set_filename(self, value):
                 self._set_filename(value)
             else:
                 self._texture = None
-                self._img_iterate()
             return
         else:
             # if we already got a texture, it will be automatically reloaded.


Test patch:
Repository: kivy/kivy

Issue:
PermissionError is not available in Python2.7
<!--
The issue tracker is a tool to address bugs.
Please use the #support Discord channel at https://chat.kivy.org/ or Stack Overflow for
support questions, more information at https://git.io/vM1yQ.

Before opening a new issue, make sure you do the following:
    * check that your issue isn't already filed: https://git.io/vM1iE
    * prepare a short, runnable example that reproduces the issue
    * reproduce the problem with the latest development version of Kivy
    * double-check that the issue is indeed a bug and not a support request
-->

### Versions

* Python: 2.7
* OS: Any
* Kivy: 1.11.0rc1 (ef216431d5b2762480596ed4a2c93a5ecbd5a355)
* Kivy installation method: Installed following [official instructions](https://kivy.org/doc/stable/installation/installation-windows.html#use-development-kivy)

### Description

`PermissionError` isn't builtin error in Python2, so this line in `logger.py` will raise an error https://github.com/kivy/kivy/blob/ef216431d5b2762480596ed4a2c93a5ecbd5a355/kivy/logger.py#L150



Discussion:

Resolving patch:
diff --git a/kivy/logger.py b/kivy/logger.py
--- a/kivy/logger.py
+++ b/kivy/logger.py
@@ -65,6 +65,11 @@
 __all__ = (
     'Logger', 'LOG_LEVELS', 'COLORS', 'LoggerHistory', 'file_log_handler')
 
+try:
+    PermissionError
+except NameError:  # Python 2
+    PermissionError = OSError, IOError
+
 Logger = None
 
 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(8))


Test patch:
Repository: kivy/kivy

Issue:
Carousel.remove_widget() doesn't remove the container of a child
### Versions

* Python: 3.7.1
* OS: Linux Mint 18.2
* Kivy: v2.0.0.dev0, git-e828f22
* Kivy installation method: `pip install -e`

### Code and Logs

```python
from kivy.uix.carousel import Carousel
from kivy.uix.widget import Widget

c = Carousel()

for i in range(5):
    w = Widget()
    c.add_widget(w)
    c.remove_widget(w)
    print(len(c.children), len(c.slides))
```

```
1 0
2 0
3 0
4 0
5 0
```


Discussion:

Resolving patch:
diff --git a/kivy/uix/carousel.py b/kivy/uix/carousel.py
--- a/kivy/uix/carousel.py
+++ b/kivy/uix/carousel.py
@@ -651,6 +651,7 @@ def remove_widget(self, widget, *args, **kwargs):
         if widget in self.slides:
             slide = widget.parent
             self.slides.remove(widget)
+            super(Carousel, self).remove_widget(slide)
             return slide.remove_widget(widget, *args, **kwargs)
         return super(Carousel, self).remove_widget(widget, *args, **kwargs)
 


Test patch:
diff --git a/kivy/tests/test_uix_carousel.py b/kivy/tests/test_uix_carousel.py
new file mode 100644
--- /dev/null
+++ b/kivy/tests/test_uix_carousel.py
@@ -0,0 +1,15 @@
+import pytest
+
+
+def test_remove_widget():
+    from kivy.uix.carousel import Carousel
+    from kivy.uix.widget import Widget
+
+    c = Carousel()
+    w = Widget()
+    c.add_widget(w)
+    assert len(c.children) == 1
+    assert len(c.slides) == 1
+    c.remove_widget(w)
+    assert len(c.children) == 0
+    assert len(c.slides) == 0
Repository: kivy/kivy

Issue:
Deprecated property "<AliasProperty name=filename>" of object "<kivy.core.audio(...)>" was accessed, it will be removed in a future version
### Versions

* Python: 3.7
* OS: independent
* Kivy: 1.11.1
* Kivy installation method: pip

### Description

The message displayed in title appears in the kivy logs when you load an audio using the default ```SoundLoader``` classes in ```kivy/core/audio``` files, excepting ```audio_ffpyplayer.py```. I was reading those files and realised that it happens because they are using ```self.filename``` instead of ```self.source```. As they belong to the kivy main files, the use of deprecated stuff should be replaced.

### Code and Logs
```python
from kivy.core.audio import SoundLoader

sound = SoundLoader.load('mytest.wav')
if sound:
    print("Sound found at %s" % sound.source)
    print("Sound is %.3f seconds" % sound.length)
    sound.play()
```

Example, when using SDL2:
```python
[WARNING] Deprecated property "<AliasProperty name=filename>" of object "<kivy.core.audio.audio_sdl2.SoundSDL2>" was accessed, it will be removed in a future version
```

P.S: I don't know if the deprecation warnings in ```kivy/core/audio/__init__.py``` should be removed too.


Discussion:

Resolving patch:
diff --git a/kivy/core/audio/audio_avplayer.py b/kivy/core/audio/audio_avplayer.py
--- a/kivy/core/audio/audio_avplayer.py
+++ b/kivy/core/audio/audio_avplayer.py
@@ -28,7 +28,7 @@ def __init__(self, **kwargs):
 
     def load(self):
         self.unload()
-        fn = NSString.alloc().initWithUTF8String_(self.filename)
+        fn = NSString.alloc().initWithUTF8String_(self.source)
         url = NSURL.alloc().initFileURLWithPath_(fn)
         self._avplayer = AVAudioPlayer.alloc().initWithContentsOfURL_error_(
             url, None)
diff --git a/kivy/core/audio/audio_gstplayer.py b/kivy/core/audio/audio_gstplayer.py
--- a/kivy/core/audio/audio_gstplayer.py
+++ b/kivy/core/audio/audio_gstplayer.py
@@ -90,7 +90,7 @@ def on_volume(self, instance, volume):
         self.player.set_volume(volume)
 
     def _get_uri(self):
-        uri = self.filename
+        uri = self.source
         if not uri:
             return
         if '://' not in uri:
diff --git a/kivy/core/audio/audio_pygame.py b/kivy/core/audio/audio_pygame.py
--- a/kivy/core/audio/audio_pygame.py
+++ b/kivy/core/audio/audio_pygame.py
@@ -91,9 +91,9 @@ def stop(self):
 
     def load(self):
         self.unload()
-        if self.filename is None:
+        if self.source is None:
             return
-        self._data = mixer.Sound(self.filename)
+        self._data = mixer.Sound(self.source)
 
     def unload(self):
         self.stop()


Test patch:
Repository: kivy/kivy

Issue:
incorrect platform detection on Android
The platform in the module kiv.utils returns linux on Android platform. It should return  Android.

Tested on a M10 Lenovo tablet running Android 8.1 with pydroid3.



Discussion:

Resolving patch:
diff --git a/kivy/utils.py b/kivy/utils.py
--- a/kivy/utils.py
+++ b/kivy/utils.py
@@ -424,9 +424,12 @@ def format_bytes_to_human(size, precision=2):
 
 def _get_platform():
     # On Android sys.platform returns 'linux2', so prefer to check the
-    # presence of python-for-android environment variables (ANDROID_ARGUMENT
-    # or ANDROID_PRIVATE).
-    if 'ANDROID_ARGUMENT' in environ:
+    # existence of system specific commands and files
+    if (
+            path.exists('/default.prop')
+            and path.exists('/system/bin/logcat')
+            and path.exists('/system/xbin')
+    ):
         return 'android'
     elif environ.get('KIVY_BUILD', '') == 'ios':
         return 'ios'


Test patch:
diff --git a/kivy/tests/test_utils.py b/kivy/tests/test_utils.py
--- a/kivy/tests/test_utils.py
+++ b/kivy/tests/test_utils.py
@@ -191,10 +191,21 @@ def test_reify(self):
         assert first == second
 
     def test_Platform_android(self):
-        with patch.dict('os.environ', {'ANDROID_ARGUMENT': ''}):
+        # modified os.path.exists function
+        # for test purpose
+        def modified_path_exists(p):
+            valid_paths = ['/default.prop',
+                           '/system/bin/logcat',
+                           '/system/xbin']
+            if p in valid_paths:
+                return True
+            return False
+
+        with patch(target='os.path.exists',
+                   side_effect=modified_path_exists):
             pf = _get_platform()
             self.assertTrue(pf == 'android')
-        self.assertNotIn('ANDROID_ARGUMENT', os.environ)
+        self.assertFalse(os.path.exists('/default.prop'))
 
     def test_Platform_ios(self):
         with patch.dict('os.environ', {'KIVY_BUILD': 'ios'}):
Repository: kivy/kivy

Issue:
HID input missing *_abs_* parameter documentation
**Is your feature request related to a problem? Please describe.**

The parameters:
* min_abs_x
* min_abs_y
* max_abs_x
* max_abs_y

are not documented: [HID input doc](https://kivy.org/doc/stable/api-kivy.input.providers.hidinput.html)

I found the parameters by accident and they were the solution to [my problem](https://groups.google.com/forum/embed/?place=forum%2Fkivy-users&hidesubject=true&hideforumtitle=true&showsearch=true&showpopout=true&parenturl=https%3A%2F%2Fkivy.org%2F%23#!topic/kivy-users/VgV5pTQEmBU)


**Describe the solution you'd like**
Add these parameters to the documentation page of HID input.

**Describe alternatives you've considered**
None.

**Additional context**
Could be useful for others who have this type of problem or are trying to calibrate their touch screens.  



Discussion:

Resolving patch:
diff --git a/kivy/input/providers/hidinput.py b/kivy/input/providers/hidinput.py
--- a/kivy/input/providers/hidinput.py
+++ b/kivy/input/providers/hidinput.py
@@ -21,10 +21,14 @@
 
 * invert_x : 1 to invert X axis
 * invert_y : 1 to invert Y axis
-* min_position_x : X minimum
-* max_position_x : X maximum
-* min_position_y : Y minimum
-* max_position_y : Y maximum
+* min_position_x : X relative minimum
+* max_position_x : X relative maximum
+* min_position_y : Y relative minimum
+* max_position_y : Y relative maximum
+* min_abs_x : X absolute minimum
+* min_abs_y : Y absolute minimum
+* max_abs_x : X absolute maximum
+* max_abs_y : Y absolute maximum
 * min_pressure : pressure minimum
 * max_pressure : pressure maximum
 * rotation : rotate the input coordinate (0, 90, 180, 270)


Test patch:
Repository: kivy/kivy

Issue:
Documentation issue with on_ref_press
In [kivy/uix/label.py L1008](https://github.com/kivy/kivy/blob/master/kivy/uix/label.py#L1008), there is a documentation issue with on_ref_press.

`widget.on_ref_press(print_it)` should be `widget.bind(on_ref_press=print_it)`.


Discussion:
Indeed, feel free to edit directly in the page you linked (using the :pen: button at the top-right), that'll create a pull request and you'll be officially a contributor :)

Resolving patch:
diff --git a/kivy/uix/label.py b/kivy/uix/label.py
--- a/kivy/uix/label.py
+++ b/kivy/uix/label.py
@@ -1005,7 +1005,7 @@ def on_ref_press(self, ref):
         def print_it(instance, value):
             print('User click on', value)
         widget = Label(text='Hello [ref=world]World[/ref]', markup=True)
-        widget.on_ref_press(print_it)
+        widget.bind(on_ref_press=print_it)
 
     .. note::
 


Test patch:
Repository: kivy/kivy

Issue:
ColoredFormatter.format() mutates `record`
**Software Versions**
* Python: 3.6.9
* OS: Ubuntu 18.04 LTS
* Kivy: 1.11.1
* Kivy installation method: pip

**Describe the bug**
`ColoredFormatter.format(self, record)` mutates the `record` argument.

This causes other, custom logging handlers to get the mutated `record` argument passed to *their* `format()` methods, which they may not be able to deal with well (e.g. due to the color codes in `record.levelname`).

**Expected behavior**
`ColoredFormatter.format(self, record)` should not mutate its `record` argument.

**To Reproduce**
With any Kivy test app:
```python
class LogfileFormatter(logging.Formatter):
    def format(self, record):
        return "test " + super().format(record)


if __name__ == '__main__':
    fm = LogfileFormatter('[%(levelname)-7s] %(message)s')
    fh = logging.FileHandler("tests/test_pause_buttons.run_log", mode='w')
    fh.setFormatter(fm)

    Logger.addHandler(fh)
    TestApp().run()
    Logger.removeHandler(fh)
```

**Additional context**
This problem could be resolved with a
```
    record = copy(record)
```
statement at the top of `ColoredFormatter.format(self, record)`.



Discussion:

Resolving patch:
diff --git a/kivy/logger.py b/kivy/logger.py
--- a/kivy/logger.py
+++ b/kivy/logger.py
@@ -88,10 +88,13 @@
 import logging
 import os
 import sys
-import kivy
+import copy
 from random import randint
 from functools import partial
 
+import kivy
+
+
 __all__ = (
     'Logger', 'LOG_LEVELS', 'COLORS', 'LoggerHistory', 'file_log_handler')
 
@@ -286,6 +289,9 @@ def __init__(self, msg, use_color=True):
         self.use_color = use_color
 
     def format(self, record):
+        """Apply terminal color code to the record"""
+        # deepcopy so we do not mess up the record for other formatters
+        record = copy.deepcopy(record)
         try:
             msg = record.msg.split(':', 1)
             if len(msg) == 2:


Test patch:
Repository: kivy/kivy

Issue:
Conda kivy package doesn't print its own version
**Software Versions**
* Python: 3.7
* OS: Arch Linux
* Kivy: ?
* Kivy installation method: conda install -c conda-forge kivy

**Describe the bug**
The current conda forge kivy package doesn't print its own version like the pip package.

**Expected behavior**
It is supposed to print something like:
```
[INFO   ] [Kivy        ] v1.11.1
```

**To Reproduce**
- install the package: `conda install -c conda-forge kivy`
- `python -c "import kivy; print(kivy._KIVY_RELEASE)"`

**Code and Logs and screenshots**
```
$ python -c "import kivy; print(kivy._KIVY_RELEASE)"
[INFO   ] [Logger      ] Record log in /home/tito/.kivy/logs/kivy_20-11-06_3.txt
[INFO   ] [Kivy        ] Installed at "/home/tito/.conda/envs/glitter2/lib/python3.7/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) 
[GCC 7.5.0]
[INFO   ] [Python      ] Interpreter at "/home/tito/.conda/envs/glitter2/bin/python"
False
```

The `kivy/base.py` code check either if it's a RELEASE version, on a development version that have a git hash. But conda package don't have.
So i guess we are missing the RELEASE tag?




Discussion:
Can you check for sure which version you're using? Because I'm looking at https://anaconda.org/conda-forge/kivy/1.11.1/download/linux-64/kivy-1.11.1-py36hb227714_3.tar.bz2 and the code looks correct.

I suspect you installed 2.0.0rc4, which does seem to have this issue since we don't add a git hash or date for conda. However, I'm concerned that conda would install a rc version automatically. I had believed that stable is always considered larger than rc!?

Resolving patch:
diff --git a/kivy/__init__.py b/kivy/__init__.py
--- a/kivy/__init__.py
+++ b/kivy/__init__.py
@@ -476,11 +476,11 @@ def kivy_usage():
 for msg in _logging_msgs:
     Logger.info(msg)
 
-if _KIVY_RELEASE:
-    Logger.info('Kivy: v%s' % __version__)
-elif not _KIVY_RELEASE and _kivy_git_hash and _kivy_build_date:
+if not _KIVY_RELEASE and _kivy_git_hash and _kivy_build_date:
     Logger.info('Kivy: v%s, git-%s, %s' % (
         __version__, _kivy_git_hash[:7], _kivy_build_date))
+else:
+    Logger.info('Kivy: v%s' % __version__)
 Logger.info('Kivy: Installed at "{}"'.format(__file__))
 Logger.info('Python: v{}'.format(sys.version))
 Logger.info('Python: Interpreter at "{}"'.format(sys.executable))


Test patch:
Repository: kivy/kivy

Issue:
export_to_png scale argument not working.
**Software Versions**
* Python: 3.9.1
* OS: Windows 10 19041.685
* Kivy: 2.0
* Kivy installation method: pip install kivy[full]

**Bug description**
export_to_png is not passing scale argument to export_as_image:
self.export_as_image().save(filename, flipped=False)

**Expected behavior**
Pass the scale argument to export_as_image, to then save the image with custom scale:
self.export_as_image(*args, **kwargs).save(filename, flipped=False)



Discussion:
https://github.com/kivy/kivy/blob/2.0.0/kivy/uix/widget.py#L723

duh >_>
That could be an easy fix.

Resolving patch:
diff --git a/kivy/uix/widget.py b/kivy/uix/widget.py
--- a/kivy/uix/widget.py
+++ b/kivy/uix/widget.py
@@ -720,7 +720,7 @@ def export_to_png(self, filename, *args, **kwargs):
 
                 .. versionadded:: 1.11.0
         '''
-        self.export_as_image().save(filename, flipped=False)
+        self.export_as_image(*args, **kwargs).save(filename, flipped=False)
 
     def export_as_image(self, *args, **kwargs):
         '''Return an core :class:`~kivy.core.image.Image` of the actual


Test patch:
diff --git a/kivy/tests/test_widget.py b/kivy/tests/test_widget.py
--- a/kivy/tests/test_widget.py
+++ b/kivy/tests/test_widget.py
@@ -82,9 +82,9 @@ def test_export_to_png(self):
         wid.export_to_png(join(tmp, 'b.png'), scale=.5)
         wid.export_to_png(join(tmp, 'c.png'), scale=2)
 
-        CoreImage(join(tmp, 'a.png')).size == (200, 100)
-        CoreImage(join(tmp, 'b.png')).size == (100, 50)
-        CoreImage(join(tmp, 'c.png')).size == (400, 200)
+        self.assertEqual(CoreImage(join(tmp, 'a.png')).size, (200, 100))
+        self.assertEqual(CoreImage(join(tmp, 'b.png')).size, (100, 50))
+        self.assertEqual(CoreImage(join(tmp, 'c.png')).size, (400, 200))
         rmtree(tmp)
 
         self.root.remove_widget(wid)