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

Issue:
Errors when compiling Python3 code
Well, as discussed on IRC, we want to collect all Python3 problems here:

When installing python3 packages I have in my testing PPA I get this (here prebuilt via pbuilder locally):

```
[...]
Setting up python3-kivy (1.8.0) ...
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_egl_rpi.py", line 77
    except BaseException, inst:
                        ^
SyntaxError: invalid syntax

dpkg: error processing python3-kivy (--install):
 subprocess installed post-installation script returned error exit status 1
Setting up python-kivy (1.8.0) ...
Setting up kivy-examples (1.8.0) ...
  File "/usr/share/kivy-examples/3Drendering/objloader.py", line 140
    raise ValueError, "mtl file doesn't start with newmtl stmt"
                    ^
SyntaxError: invalid syntax

[...]
```



Discussion:

Resolving patch:
diff --git a/kivy/core/window/window_egl_rpi.py b/kivy/core/window/window_egl_rpi.py
--- a/kivy/core/window/window_egl_rpi.py
+++ b/kivy/core/window/window_egl_rpi.py
@@ -74,7 +74,7 @@ def mainloop(self):
         while not EventLoop.quit and EventLoop.status == 'started':
             try:
                 self._mainloop()
-            except BaseException, inst:
+            except BaseException as inst:
                 raise
                 '''
                 # use exception manager first


Test patch:
Repository: kivy/kivy

Issue:
AsyncImage not loading
AsyncImage does not load. Loader stays spinning forever: http://pbrd.co/16ak452
The screenshot is from the AsyncImage widget example. I've tried my own code with working links, same result.

Cloned Kivy 1.8.0 dev today, 13 june.

The only error I see is on the pic: "No module named request"



Discussion:

Resolving patch:
diff --git a/kivy/loader.py b/kivy/loader.py
--- a/kivy/loader.py
+++ b/kivy/loader.py
@@ -40,6 +40,7 @@
 from kivy.clock import Clock
 from kivy.cache import Cache
 from kivy.core.image import ImageLoader, Image
+from kivy.compat import PY2
 
 from collections import deque
 from time import sleep
@@ -276,7 +277,10 @@ def _load_local(self, filename, kwargs):
     def _load_urllib(self, filename, kwargs):
         '''(internal) Loading a network file. First download it, save it to a
         temporary file, and pass it to _load_local()'''
-        import urllib.request, urllib.error, urllib.parse
+        if PY2:
+            import urllib2 as urllib_request
+        else:
+            import urllib.request as urllib_request
         proto = filename.split(':', 1)[0]
         if proto == 'smb':
             try:
@@ -297,10 +301,10 @@ def _load_urllib(self, filename, kwargs):
 
             if proto == 'smb':
                 # read from samba shares
-                fd = urllib.request.build_opener(SMBHandler).open(filename)
+                fd = urllib_request.build_opener(SMBHandler).open(filename)
             else:
                 # read from internet
-                fd = urllib.request.urlopen(filename)
+                fd = urllib_request.urlopen(filename)
             idata = fd.read()
             fd.close()
             fd = None


Test patch:
Repository: kivy/kivy

Issue:
Kivy 1.8.0 dev: touch.is_double_tap is set allways to true on Windows
Hello,
On MS Windows with Kivy 1.8.0 dev: If you press a button twice, even after a greater time gap between the touches, you always get touch.is_double_tap == True on the second tap. 

Does not appear with 1.7.1 on Android.

Greetings

Carsten



Discussion:

Resolving patch:
diff --git a/kivy/input/postproc/doubletap.py b/kivy/input/postproc/doubletap.py
--- a/kivy/input/postproc/doubletap.py
+++ b/kivy/input/postproc/doubletap.py
@@ -7,6 +7,7 @@
 
 __all__ = ('InputPostprocDoubleTap', )
 
+from time import time
 from kivy.config import Config
 from kivy.vector import Vector
 from kivy.clock import Clock
@@ -77,8 +78,8 @@ def process(self, events):
                 double_tap = self.find_double_tap(touch)
                 if double_tap:
                     touch.is_double_tap = True
-                    time = touch.time_start - double_tap.time_start
-                    touch.double_tap_time = time
+                    tap_time = touch.time_start - double_tap.time_start
+                    touch.double_tap_time = tap_time
                     distance = double_tap.double_tap_distance
                     touch.double_tap_distance = distance
 
@@ -86,7 +87,7 @@ def process(self, events):
             self.touches[touch.uid] = (etype, touch)
 
         # second, check if up-touch is timeout for double tap
-        time_current = Clock.get_time()
+        time_current = time()
         to_delete = []
         for touchid in self.touches.keys():
             etype, touch = self.touches[touchid]
diff --git a/kivy/input/postproc/tripletap.py b/kivy/input/postproc/tripletap.py
--- a/kivy/input/postproc/tripletap.py
+++ b/kivy/input/postproc/tripletap.py
@@ -9,6 +9,7 @@
 
 __all__ = ('InputPostprocTripleTap', )
 
+from time import time
 from kivy.config import Config
 from kivy.vector import Vector
 from kivy.clock import Clock
@@ -82,8 +83,8 @@ def process(self, events):
                 if triple_tap:
                     touch.is_double_tap = False
                     touch.is_triple_tap = True
-                    time = touch.time_start - triple_tap.time_start
-                    touch.triple_tap_time = time
+                    tap_time = touch.time_start - triple_tap.time_start
+                    touch.triple_tap_time = tap_time
                     distance = triple_tap.triple_tap_distance
                     touch.triple_tap_distance = distance
 
@@ -91,7 +92,7 @@ def process(self, events):
             self.touches[touch.uid] = (etype, touch)
 
         # second, check if up-touch is timeout for triple tap
-        time_current = Clock.get_time()
+        time_current = time()
         to_delete = []
         for touchid in self.touches.keys():
             etype, touch = self.touches[touchid]


Test patch:
Repository: kivy/kivy

Issue:
kivy.network.urlrequest: No callback parameter: on_failure
Documentation for urlrequest shows a parameter
on_failure: callback(request, result)
which haven't been implementet.



Discussion:

Resolving patch:
diff --git a/kivy/network/urlrequest.py b/kivy/network/urlrequest.py
--- a/kivy/network/urlrequest.py
+++ b/kivy/network/urlrequest.py
@@ -138,6 +138,8 @@ class UrlRequest(Thread):
     .. versionadded:: 1.8.0
         Parameter `decode` added.
         Parameter `file_path` added.
+        Parameter `on_redirect` added.
+        Parameter `on_failure` added.
     '''
 
     def __init__(self, url, on_success=None, on_redirect=None,


Test patch:
Repository: kivy/kivy

Issue:
simplelistadapter should accept objects inheriting from list or tuple
I'll found it usefull if it was possible to extend the list object that I pass to the simplelistadapter, but an exception is raised.

Reproduce :

``` python
from kivy.adapters.simplelistadapter import SimpleListAdapter
class ExtendedList(list):
        pass

list_adapter = SimpleListAdapter(data=ExtendedList())
```

A solution :
In kivy/adapters/simplelistadapter.py

``` python
 47         if type(kwargs['data']) not in (tuple, list):                           
 48             raise Exception('list adapter: data must be a tuple or list') 
```

May be replaced by:

``` python
if not isinstance(kwargs['data'], list) and not isinstance(kwargs['data'], tuple)
```



Discussion:

Resolving patch:
diff --git a/kivy/adapters/simplelistadapter.py b/kivy/adapters/simplelistadapter.py
--- a/kivy/adapters/simplelistadapter.py
+++ b/kivy/adapters/simplelistadapter.py
@@ -44,7 +44,8 @@ class SimpleListAdapter(Adapter):
     def __init__(self, **kwargs):
         if 'data' not in kwargs:
             raise Exception('list adapter: input must include data argument')
-        if type(kwargs['data']) not in (tuple, list):
+        if not isinstance(kwargs['data'], list) and \
+                not isinstance(kwargs['data'], tuple):
             raise Exception('list adapter: data must be a tuple or list')
         super(SimpleListAdapter, self).__init__(**kwargs)
 


Test patch:
diff --git a/kivy/tests/test_adapters.py b/kivy/tests/test_adapters.py
--- a/kivy/tests/test_adapters.py
+++ b/kivy/tests/test_adapters.py
@@ -441,6 +441,18 @@ def test_simple_list_adapter_for_exceptions(self):
         msg = 'list adapter: data must be a tuple or list'
         self.assertEqual(str(cm.exception), msg)
 
+    def test_simple_list_adapter_for_inherited_list(self):
+        # Test for issue 1396 : list, tuple and inheritance
+        class ExtendedList(list):
+            pass
+        class ExtendedTuple(tuple):
+            pass
+        # Equivalent to assertNotRaise
+        simple_list_adapter = SimpleListAdapter(data=ExtendedList(),
+                                  template='CustomSimpleListItem')
+        simple_list_adapter = SimpleListAdapter(data=ExtendedTuple(),
+                                  template='CustomSimpleListItem')
+
     def test_simple_list_adapter_with_template(self):
         list_item_args_converter = \
                 lambda row_index, obj: {'text': str(obj),
Repository: kivy/kivy

Issue:
Kivy reads pyinstaller options
When running pyinstaller with extra pyinstaller command line option the command options are read by kivy and since it doesn't make sense to kivy, kivy crashes.

E.g. command line option:

```
python pyinstaller.py --log-level=DEBUG touchtracer\touchtracer.spec
```

where touchtracer.spec is :

```
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
install_hooks(globals())
# -*- mode: python -*-
a = Analysis(['..\\kivy\\examples\\demo\\touchtracer\\main.py'],
             pathex=['C:\\kivy-dev\\pyinstaller-2.0'],
             hiddenimports=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=1,
          name=os.path.join('build\\pyi.win32\\touchtracer', 'touchtracer.exe'),
          debug=False,
          strip=None,
          upx=True,
          console=True )
coll = COLLECT(exe, Tree('../kivy/examples/demo/touchtracer/'),
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name=os.path.join('dist', 'touchtracer'))
```

Will result in this errors:

```
...
    1441 DEBUG: Analyzing _struct._clearcache
1441 DEBUG: Analyzing _struct.__doc__
1458 DEBUG: Dependent assemblies of C:\kivy-dev\Python\python.exe:
1458 DEBUG: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none
[INFO              ] Kivy v1.8.0-dev
1474 INFO: Kivy v1.8.0-dev
[INFO              ] [Logger      ] Record log in C:\Users\n\Documents\.kivy\logs\kivy_13-09-02_44.txt
1494 INFO: [Logger      ] Record log in C:\Users\n\Documents\.kivy\logs\kivy_13-09-02_44.txt
[ERROR             ] [Core        ] option --log-level not recognized
1483 ERROR: [Core        ] option --log-level not recognized
Kivy Usage: pyinstaller.py [OPTION...]::

        -h, --help
            Prints this help message.
        -d, --debug
            Shows debug log
...
```



Discussion:

Resolving patch:
diff --git a/kivy/__init__.py b/kivy/__init__.py
--- a/kivy/__init__.py
+++ b/kivy/__init__.py
@@ -242,6 +242,8 @@ def kivy_usage():
     environ['KIVY_DOC_INCLUDE'] = '1'
 if any('nosetests' in arg for arg in sys.argv):
     environ['KIVY_UNITTEST'] = '1'
+if any('pyinstaller' in arg for arg in sys.argv):
+    environ['KIVY_PACKAGING'] = '1'
 
 if not environ.get('KIVY_DOC_INCLUDE'):
     # Configuration management
@@ -278,8 +280,7 @@ def kivy_usage():
     Logger.setLevel(level=LOG_LEVELS.get('debug'))
 
     # Can be overrided in command line
-    if 'KIVY_UNITTEST' not in environ:
-
+    if 'KIVY_UNITTEST' not in environ and 'KIVY_PACKAGING' not in environ:
         # save sys argv, otherwize, gstreamer use it and display help..
         sys_argv = sys.argv
         sys.argv = sys.argv[:1]


Test patch:
Repository: kivy/kivy

Issue:
The latest vesion of kivy setup script has some issues
I have tested it on multiple systems, per irc discussion others get this error too, kivy itself is installed.

<pre><code>
Installed /usr/local/lib/python2.7/dist-packages/Kivy-1.8.0_dev-py2.7-linux-x86_64.egg
Processing dependencies for Kivy==1.8.0-dev
Searching for garden==0.1
Best match: garden 0.1
Doing git clone from https://github.com/kivy-garden/garden.git to /tmp/easy_install-8T839w/garden.git@0.1
Checking out 0.1
Processing garden.git@0.1
Writing /tmp/easy_install-8T839w/garden.git@0.1/setup.cfg
Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-8T839w/garden.git@0.1/egg-dist-tmp-1bEg1S
 warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install
 
 zip_safe flag not set; analyzing archive contents...
Adding Kivy-Garden 0.1 to easy-install.pth file
Installing garden script to /usr/local/bin
Installing garden.bat script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/Kivy_Garden-0.1-py2.7.egg
 error: Could not find required distribution garden==0.1
</code></pre>




Discussion:
Yes, this is related to a contribution I made. I've been intending to put some more work into it, but other commitments have been getting in the way.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -550,7 +550,7 @@ def get_extensions_from_sources(sources):
         'Topic :: Scientific/Engineering :: Visualization',
         'Topic :: Software Development :: Libraries :: Application Frameworks',
         'Topic :: Software Development :: User Interfaces'],
-    dependency_links=['git+https://github.com/kivy-garden/garden.git@0.1#egg=garden-0.1'],
-    install_requires=['garden==0.1'],
+    dependency_links=['https://github.com/kivy-garden/garden/archive/0.1.1.zip#egg=Kivy-Garden-0.1.1'],
+    install_requires=['Kivy-Garden==0.1.1'],
     )
 


Test patch:
Repository: kivy/kivy

Issue:
Improve the docs by adding links to show the source code
As per previous discussion on irc, and more recently on the [mailing list](https://groups.google.com/forum/#!topic/kivy-users/L_CnFoWkV6A), the online docs could be improved by including automatic links to the kivy source.

Sphinx already has at least one external module to provide nicely formatted source like this (http://sphinx-doc.org/ext/viewcode.html), but this probably isn't the only way, and maybe it would be better anyway to try and link to the github master.

I vaguely remember @tshirtman having a demo of something like this a while ago.



Discussion:

Resolving patch:
diff --git a/doc/sources/conf.py b/doc/sources/conf.py
--- a/doc/sources/conf.py
+++ b/doc/sources/conf.py
@@ -23,7 +23,9 @@
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['autodoc', 'sphinx.ext.todo', 'preprocess', 'sphinx.ext.ifconfig']
+extensions = [
+    'autodoc', 'sphinx.ext.todo', 'preprocess', 'sphinx.ext.ifconfig',
+    'sphinx.ext.viewcode']
 
 # Todo configuration
 todo_include_todos = True


Test patch:
Repository: kivy/kivy

Issue:
Inspector and Popups
The commit 6e8cffd, reverting 2b71292 solves one problem, but causes another: Open `Popup` widgets cannot be inspected again. To see this, run `examples/widgets/popup_with_kv.py` with the inspector, open the `Popup` and try to inspect it. The `Button` "behind" the `Popup` will be selected instead.



Discussion:
This may be related to #1338.


Resolving patch:
diff --git a/kivy/modules/inspector.py b/kivy/modules/inspector.py
--- a/kivy/modules/inspector.py
+++ b/kivy/modules/inspector.py
@@ -70,6 +70,7 @@ def build(self):
 from kivy.uix.gridlayout import GridLayout
 from kivy.uix.floatlayout import FloatLayout
 from kivy.uix.boxlayout import BoxLayout
+from kivy.uix.modalview import ModalView
 from kivy.graphics import Color, Rectangle, PushMatrix, PopMatrix, \
         Translate, Rotate, Scale
 from kivy.properties import ObjectProperty, BooleanProperty, ListProperty, \
@@ -78,10 +79,10 @@ def build(self):
 from kivy.graphics.texture import Texture
 from kivy.clock import Clock
 from functools import partial
+from itertools import chain
 from kivy.lang import Builder
 from kivy.vector import Vector
 
-
 Builder.load_string('''
 <Inspector>:
     layout: layout
@@ -259,8 +260,14 @@ def on_window_children(self, win, children):
 
     def highlight_at(self, x, y):
         widget = None
-        # reverse the loop - look at children on top first
-        for child in reversed(self.win.children):
+        # reverse the loop - look at children on top first and
+        # modalviews before others
+        win_children = self.win.children
+        children = chain(
+            (c for c in reversed(win_children) if isinstance(c, ModalView)),
+            (c for c in reversed(win_children) if not isinstance(c, ModalView))
+        )
+        for child in children:
             if child is self:
                 continue
             widget = self.pick(child, x, y)


Test patch:
Repository: kivy/kivy

Issue:
Window.screenshot() hangs if you provide a filename which already exists.
WindowBase.screenshot() has some code to search for the next 'screenshot-NNN.png' file available. But if you provide your own name, and that file exists, then the searching code searches forever.



Discussion:
I suggest using datetime for the file like this (Minecraft does this) instead of using a counter:

``` python
import datetime

DATETIME_FMT = '%Y-%m-%d_%H.%M.%S'

def get_now_as_str():
    return datetime.datetime.now().strftime(DATETIME_FMT)

get_now_as_str() #=> '2013-09-18_20.19.20'
```

or with microseconds to make it unlikely there are two with the same (of course the bug should still get fixed):

``` python
import datetime

DATETIME_FMT = '%Y-%m-%d_%H.%M.%S.%f'

def get_now_as_str():
    return datetime.datetime.now().strftime(DATETIME_FMT)

get_now_as_str() #=> '2013-09-18_20.52.24.428110'
```

Also shouldn't there be a way to specify the path where the screenshot gets saved instead of just saving it in the current working directory?


Resolving patch:
diff --git a/kivy/core/window/__init__.py b/kivy/core/window/__init__.py
--- a/kivy/core/window/__init__.py
+++ b/kivy/core/window/__init__.py
@@ -733,14 +733,17 @@ def update_childsize(self, childs=None):
                 elif key == 'center_y':
                     w.center_y = value * height
 
-    def screenshot(self, name='screenshot%(counter)04d.png'):
+    def screenshot(self, name='screenshot{:04d}.png'):
         '''Save the actual displayed image in a file
         '''
         i = 0
         path = None
+        if name != 'screenshot{:04d}.png':
+            _ext = name.split('.')[-1]
+            name = ''.join((name[:-(len(_ext) + 1)], '{:04d}.', _ext))
         while True:
             i += 1
-            path = join(getcwd(), name % {'counter': i})
+            path = join(getcwd(), name.format(i))
             if not exists(path):
                 break
         return path
@@ -920,9 +923,9 @@ def request_keyboard(self, callback, target, input_type='text'):
                 target attached if you're using the keyboard in a multi user
                 mode.
             `input_type`: string
-                Choose the type of soft keyboard to request. Can be one of 'text',
-                'number', 'url', 'mail', 'datetime', 'tel', 'address'.
-                
+                Choose the type of soft keyboard to request. Can be one of
+                'text', 'number', 'url', 'mail', 'datetime', 'tel', 'address'.
+
                 .. versionadded:: 1.8.0
 
         :Return:


Test patch:
Repository: kivy/kivy

Issue:
Crash using weakmethod with python3
It just happen to me once, not currently reproducible, with python3:

```
   File "/home/tito/code/kivy/kivy/app.py", line 600, in run
     runTouchApp()
   File "/home/tito/code/kivy/kivy/base.py", line 454, in runTouchApp
     EventLoop.window.mainloop()
   File "/home/tito/code/kivy/kivy/core/window/window_pygame.py", line 329, in mainloop
     self._mainloop()
   File "/home/tito/code/kivy/kivy/core/window/window_pygame.py", line 235, in _mainloop
     EventLoop.idle()
   File "/home/tito/code/kivy/kivy/base.py", line 294, in idle
     Clock.tick()
   File "/home/tito/code/kivy/kivy/clock.py", line 370, in tick
     self._process_events()
   File "/home/tito/code/kivy/kivy/clock.py", line 481, in _process_events
     if event.tick(self._last_tick) is False:
   File "/home/tito/code/kivy/kivy/clock.py", line 280, in tick
     ret = callback(self._dt)
   File "/home/tito/code/kivy/kivy/animation.py", line 289, in _update
     self.dispatch('on_progress', widget, progress)
   File "_event.pyx", line 272, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:3992)
   File "/home/tito/code/kivy/kivy/weakmethod.py", line 42, in __call__
     if self.proxy:
 ReferenceError: weakly-referenced object no longer exists
```



Discussion:
We need more tests / backlog to ensure this is not reproducible at all. I'll not release Kivy if it's not fixed :)

I've been stumbling on this, i reproduce 100% of the time with any TextInput in showcase (just try to edit some text)

related to #1322  ?


Resolving patch:
diff --git a/kivy/factory.py b/kivy/factory.py
--- a/kivy/factory.py
+++ b/kivy/factory.py
@@ -112,6 +112,10 @@ def unregister_from_filename(self, filename):
     def __getattr__(self, name):
         classes = self.classes
         if name not in classes:
+            if name[0] == name[0].lower():
+                # if trying to access attributes like checking for `bind`
+                # then raise AttributeError
+                raise AttributeError
             raise FactoryException('Unknown class <%s>' % name)
 
         item = classes[name]
diff --git a/kivy/weakmethod.py b/kivy/weakmethod.py
--- a/kivy/weakmethod.py
+++ b/kivy/weakmethod.py
@@ -41,8 +41,11 @@ def __call__(self):
             method.
             Returns None if the original object doesn't exist.
             '''
-            if self.proxy:
-                return getattr(self.proxy, self.method_name)
+            try:
+                if self.proxy:
+                    return getattr(self.proxy, self.method_name)
+            except ReferenceError:
+                pass
             return self.method
 
         def is_dead(self):


Test patch: