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

Issue:
TextInput hint_text is hidden on focus
Hiding the hint text on focus limits the usability of the feature, `hint_text` should always be visible unless there is text in the input.

HTML input fields also behave this way: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_placeholder.



Discussion:
I'll try fixing this. Looks simple.


Resolving patch:
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -1884,8 +1884,8 @@ def _update_graphics(self, *largs):
         sy = self.scroll_y
 
         # draw labels
-        if not self.focus and (not self._lines or (
-                not self._lines[0] and len(self._lines) == 1)):
+        if not self._lines or (
+                not self._lines[0] and len(self._lines) == 1):
             rects = self._hint_text_rects
             labels = self._hint_text_labels
             lines = self._hint_text_lines


Test patch:
Repository: kivy/kivy

Issue:
Always show the textinput cursor at the moment of touch
This is just a small annoyance, but it would be nice to clean it up. The cursor blinking timer is not started/reset on a new touch, so unless the focus gain time coincides with the time when the cursor should appear, you'll see a delay until the cursor finally appears.



Discussion:

Resolving patch:
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -447,7 +447,6 @@ class TextInput(FocusBehavior, Widget):
 
     def __init__(self, **kwargs):
         self.is_focusable = kwargs.get('is_focusable', True)
-        self._cursor_blink_time = Clock.get_time()
         self._cursor = [0, 0]
         self._selection = False
         self._selection_finished = True
@@ -1293,6 +1292,9 @@ def on_touch_down(self, touch):
         if super(TextInput, self).on_touch_down(touch):
             return True
 
+        if self.focused:
+            self._reset_cursor_blink()
+
         # Check for scroll wheel
         if 'button' in touch.profile and touch.button.startswith('scroll'):
             scroll_type = touch.button[6:]
@@ -1634,7 +1636,7 @@ def _on_textinput_focused(self, instance, value, *largs):
         if value:
             if (not (self.readonly or self.disabled) or _is_desktop and
                 self._keyboard_mode == 'system'):
-                Clock.schedule_interval(self._do_blink_cursor, 1 / 2.)
+                self._reset_cursor_blink()
                 self._editable = True
             else:
                 self._editable = False
@@ -1716,13 +1718,17 @@ def _get_text_width(self, text, tab_width, _label_cached):
     def _do_blink_cursor(self, dt):
         # Callback called by the timer to blink the cursor, according to the
         # last activity in the widget
-        b = (Clock.get_time() - self._cursor_blink_time)
-        self.cursor_blink = int(b * 2) % 2
+        self.cursor_blink = not self.cursor_blink
+
+    def _reset_cursor_blink(self):
+        Clock.unschedule(self._do_blink_cursor)
+        self.cursor_blink=0
+        Clock.schedule_interval(self._do_blink_cursor, .5)
 
     def on_cursor(self, instance, value):
-        # When the cursor is moved, reset the activity timer, and update all
-        # the graphics.
-        self._cursor_blink_time = Clock.get_time()
+        # When the cursor is moved, reset cursor blinking to keep it showing,
+        # and update all the graphics.
+        self._reset_cursor_blink()
         self._trigger_update_graphics()
 
     def _delete_line(self, idx):


Test patch:
Repository: kivy/kivy

Issue:
WM touch/pen warning messages after 1.9.1
```
[WARNING           ] [Input       ] WM_Touch/WM_Pen not supported by your version of Windows
[WARNING           ] [Base        ] Unknown <wm_touch> provider
[WARNING           ] [Base        ] Unknown <wm_pen> provider
```



Discussion:
Introduced by https://github.com/kivy/kivy/commit/5a9a29f8e8e753b38226999f66365d96fc4b6293.
@tshirtman pingly.


Resolving patch:
diff --git a/kivy/input/providers/wm_touch.py b/kivy/input/providers/wm_touch.py
--- a/kivy/input/providers/wm_touch.py
+++ b/kivy/input/providers/wm_touch.py
@@ -14,7 +14,8 @@
     TOUCHEVENTF_MOVE, SM_CYCAPTION)
 from kivy.input.motionevent import MotionEvent
 from kivy.input.shape import ShapeRect
-from kivy.core.window import Window
+
+Window = None
 
 
 class WM_MotionEvent(MotionEvent):
@@ -134,6 +135,10 @@ class RECT(Structure):
     class WM_MotionEventProvider(MotionEventProvider):
 
         def start(self):
+            global Window
+            if not Window:
+                from kivy.core.window import Window
+
             self.touch_events = deque()
             self.touches = {}
             self.uid = 0


Test patch:
Repository: kivy/kivy

Issue:
Pygame text provider does not render text opacity properly
Text renders as if opacity is set to 100% regardless of what's set in a Label's color attribute.

SDL2 works just fine.

Tested with master pulled today on Linux.

Pygame text provider does not render text opacity properly
Text renders as if opacity is set to 100% regardless of what's set in a Label's color attribute.

SDL2 works just fine.

Tested with master pulled today on Linux.



Discussion:
This was broken while fixing color handling for sdl2 because the global Color from Label style.kv was removed.

I'm not sure what would be our policy here, since pygame was deprecated, and this is not a critical bug, but we're probably open for a fix if someone provides a patch.

One the other hand the pillow text provider should be updated to reflect these color changes.

Edit: pillow text is not affected.

This was broken while fixing color handling for sdl2 because the global Color from Label style.kv was removed.

I'm not sure what would be our policy here, since pygame was deprecated, and this is not a critical bug, but we're probably open for a fix if someone provides a patch.

One the other hand the pillow text provider should be updated to reflect these color changes.

Edit: pillow text is not affected.


Resolving patch:
diff --git a/kivy/core/text/text_pygame.py b/kivy/core/text/text_pygame.py
--- a/kivy/core/text/text_pygame.py
+++ b/kivy/core/text/text_pygame.py
@@ -97,6 +97,7 @@ def _render_text(self, text, x, y):
         color[0], color[2] = color[2], color[0]
         try:
             text = font.render(text, True, color)
+            text.set_colorkey(color)
             self._pygame_surface.blit(text, (x, y), None,
                                       pygame.BLEND_RGBA_ADD)
         except pygame.error:


Test patch:
Repository: kivy/kivy

Issue:
Brittle kv import Syntax
The kv import syntax is very brittle and the error messages in the exceptions do not describe the errors in sufficient detail to address syntax errors.

Using regular expressions to parse the file, line by line, would make the syntax more forgiving of common errors.



Discussion:
Do you have logs, examples, etc?

The line "#:import Button  kivy.uix.button" will fail to parse because of a superfluous space character present.

If the regex looked something like (I'm doing this quickly without giving it a full analysis) `r"\s*#:\s*import\s+(?P<alias>[_a-zA-z][_0-9a-zA-Z]*)\s+(?P<package>\.*(?:[_a-zA-z][_0-9a-zA-Z]*)(?:\.(?:[_a-zA-z][_0-9a-zA-Z]*))*)\s*"`, it would handle at least common formatting differences without changing the current functionality.

The name "package" in the import attempts is somewhat deceptive as the "package" selection actually contains potentially package and module, which makes determining error causes more difficult.


Resolving patch:
diff --git a/kivy/lang/parser.py b/kivy/lang/parser.py
--- a/kivy/lang/parser.py
+++ b/kivy/lang/parser.py
@@ -444,7 +444,7 @@ def execute_directives(self):
                 kivy.lang.builder.Builder.load_file(ref)
             elif cmd[:7] == 'import ':
                 package = cmd[7:].strip()
-                l = package.split(' ')
+                l = package.split()
                 if len(l) != 2:
                     raise ParserException(self, ln, 'Invalid import syntax')
                 alias, package = l


Test patch:
Repository: kivy/kivy

Issue:
ScrollView stops working after exporting its content to png using export_to_png
Example to reproduce the error: 
http://pastebin.com/jv3vu0iW

Output:
Exception ValueError: 'list.remove(x): x not in list' in 'kivy.graphics.instructions.Instruction.rremove' ignored



Discussion:
The issue likely comes from the `self.parent.canvas.remove` line, since ScrollView manipulates its canvas (as seen in its add_widget overriding), and indeed, a dirty workaround is to add an intermediate widget between the widget to capture and the ScrollView (i used another GridLayout, but anything correctly containing the current GridLayout would do).

This doesn't give an easy solution, though, maybe ScrollView should avoid adding an indirection to its canvas, or export_to_png should use a function or AliasProperty to get the actual canvas, and ScrollView would override it.

hm, actually, checking that `canvas_parent_index' is not -1 does seem to fix the issue, not sure it's 100% harmless though.


Resolving patch:
diff --git a/kivy/uix/widget.py b/kivy/uix/widget.py
--- a/kivy/uix/widget.py
+++ b/kivy/uix/widget.py
@@ -603,7 +603,8 @@ def export_to_png(self, filename, *args):
 
         if self.parent is not None:
             canvas_parent_index = self.parent.canvas.indexof(self.canvas)
-            self.parent.canvas.remove(self.canvas)
+            if canvas_parent_index > -1:
+                self.parent.canvas.remove(self.canvas)
 
         fbo = Fbo(size=self.size, with_stencilbuffer=True)
 
@@ -618,7 +619,7 @@ def export_to_png(self, filename, *args):
         fbo.texture.save(filename, flipped=False)
         fbo.remove(self.canvas)
 
-        if self.parent is not None:
+        if self.parent is not None and canvas_parent_index > -1:
             self.parent.canvas.insert(canvas_parent_index, self.canvas)
 
         return True


Test patch:
Repository: kivy/kivy

Issue:
ScrollView: Imprecise touch events registered as scroll, should propogate touch
Imprecise touch events - especially on mobile/tablet - require exact accuracy even if the motion is within scroll_distance - they register as scroll events even though they really should be touch.

This leads to a cumbersome and difficult to use experience when dealing with touch aware widgets such as text boxes / buttons, etc. inside a scroll view.

If the scrollView receives a touch event within scroll_distance it should register as a touch.



Discussion:

Resolving patch:
diff --git a/kivy/uix/scrollview.py b/kivy/uix/scrollview.py
--- a/kivy/uix/scrollview.py
+++ b/kivy/uix/scrollview.py
@@ -658,6 +658,8 @@ def on_scroll_start(self, touch, check_children=True):
             'mode': 'unknown',
             'dx': 0,
             'dy': 0,
+            'y_start': touch.y,
+            'x_start': touch.x,
             'user_stopped': False,
             'frames': Clock.frames,
             'time': touch.time_start}
@@ -809,7 +811,6 @@ def on_scroll_stop(self, touch, check_children=True):
         if self._get_uid() not in touch.ud:
             return False
 
-        self._touch = None
         uid = self._get_uid()
         ud = touch.ud[uid]
         if self.do_scroll_x and self.effect_x:
@@ -827,6 +828,17 @@ def on_scroll_stop(self, touch, check_children=True):
             if not ud['user_stopped']:
                 self.simulate_touch_down(touch)
             Clock.schedule_once(partial(self._do_touch_up, touch), .2)
+
+        #check if we're touch selecting imprecisely
+        #but within range of scroll_distance
+        y_start = ud.get('y_start')
+        x_start = ud.get('x_start')
+        y_select = self.do_scroll_y and y_start and abs(y_start - touch.y) < self.scroll_distance
+        x_select = self.do_scroll_x and x_start and abs(x_start - touch.x) < self.scroll_distance
+        if ud['mode'] == 'scroll' and (x_select or y_select):
+            self.simulate_touch_down(touch)
+            Clock.schedule_once(partial(self._do_touch_up, touch), .1)
+
         Clock.unschedule(self._update_effect_bounds)
         Clock.schedule_once(self._update_effect_bounds)
 


Test patch:
Repository: kivy/kivy

Issue:
ModalView background size is not updated
Since https://github.com/kivy/kivy/pull/4136 the ModalView background is not resized when the window size changes, run `kivy/uix/modalview.py`, then resize the window.

![capture](https://cloud.githubusercontent.com/assets/7513068/14303295/159f0434-fbb2-11e5-93b3-8de02ffd4e49.PNG)



Discussion:

Resolving patch:
diff --git a/kivy/uix/modalview.py b/kivy/uix/modalview.py
--- a/kivy/uix/modalview.py
+++ b/kivy/uix/modalview.py
@@ -143,7 +143,7 @@ class ModalView(AnchorLayout):
 
     _anim_duration = NumericProperty(.1)
 
-    _window = ObjectProperty(None, allownone=True)
+    _window = ObjectProperty(None, allownone=True, rebind=True)
 
     __events__ = ('on_open', 'on_dismiss')
 


Test patch:
Repository: kivy/kivy

Issue:
handle data uris for images
ref https://github.com/kivy/kivy/pull/2692



Discussion:

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
@@ -38,6 +38,8 @@
     im = CoreImage(data, ext="png", filename="image.png")
 
 '''
+import re
+from base64 import b64decode
 
 __all__ = ('Image', 'ImageLoader', 'ImageData')
 
@@ -468,6 +470,8 @@ class Image(EventDispatcher):
     copy_attributes = ('_size', '_filename', '_texture', '_image',
                        '_mipmap', '_nocache')
 
+    data_uri_re = re.compile(r'^data:image/([^;,]*)(;[^,]*)?,(.*)$')
+
     def __init__(self, arg, **kwargs):
         # this event should be fired on animation of sequenced img's
         self.register_event_type('on_texture')
@@ -509,7 +513,19 @@ def __init__(self, arg, **kwargs):
                 filename = '__inline__'
             self.load_memory(arg, ext, filename)
         elif isinstance(arg, string_types):
-            self.filename = arg
+            groups = self.data_uri_re.findall(arg)
+            if groups:
+                self._nocache = True
+                imtype, optstr, data = groups[0]
+                options = [o for o in optstr.split(';') if o]
+                ext = imtype
+                isb64 = 'base64' in options
+                if data:
+                    if isb64:
+                        data = b64decode(data)
+                    self.load_memory(BytesIO(data), ext)
+            else:
+                self.filename = arg
         else:
             raise Exception('Unable to load image type {0!r}'.format(arg))
 
diff --git a/kivy/resources.py b/kivy/resources.py
--- a/kivy/resources.py
+++ b/kivy/resources.py
@@ -57,6 +57,8 @@ def resource_find(filename):
         output = join(path, filename)
         if exists(output):
             return output
+    if filename[:5] == 'data:':
+        return filename
     return None
 
 


Test patch:
Repository: kivy/kivy

Issue:
unicode text_hint in TextInput
using a unicode value for `hint_text` in kv (loaded with load_file) fails, i get encoding issues.

```
TextInput:
    hint_text: u'é'
```

a successful workaround is to use `decode` instead of `u''`

```
TextInput:
   hint_text: 'é'.decode('utf-8')
```

edit, this is not specific to `hint_text`, `text` has the same issue.



Discussion:

Resolving patch:
diff --git a/examples/demo/kivycatalog/main.py b/examples/demo/kivycatalog/main.py
--- a/examples/demo/kivycatalog/main.py
+++ b/examples/demo/kivycatalog/main.py
@@ -165,7 +165,7 @@ def change_kv(self, *largs):
             self.show_error(e)
 
     def show_error(self, e):
-        self.info_label.text = str(e)
+        self.info_label.text = unicode(e)
         self.anim = Animation(top=190.0, opacity=1, d=2, t='in_back') +\
             Animation(top=190.0, d=3) +\
             Animation(top=0, opacity=0, d=2)
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -2411,7 +2411,7 @@ def keyboard_on_textinput(self, window, text):
             self.delete_selection()
         self.insert_text(text, False)
 
-    def on_hint_text(self, instance, value):
+    def on__hint_text(self, instance, value):
         self._refresh_hint_text()
 
     def _refresh_hint_text(self):
@@ -2937,15 +2937,26 @@ def _set_text(self, text):
     :attr:`font_size` is a :class:`~kivy.properties.NumericProperty` and
     defaults to 10.
     '''
+    _hint_text = StringProperty('')
 
-    hint_text = StringProperty('')
+    def _set_hint_text(self, value):
+        if isinstance(value, bytes):
+            value = value.decode('utf8')
+        self._hint_text = value
+
+    def _get_hint_text(self):
+        return self._hint_text
+
+    hint_text = AliasProperty(
+        _get_hint_text, _set_hint_text, bind=('_hint_text', ))
     '''Hint text of the widget.
 
     Shown if text is '' and focus is False.
 
     .. versionadded:: 1.6.0
+    .. versionchanged:: 1.9.2
 
-    :attr:`hint_text` a :class:`~kivy.properties.StringProperty` and defaults
+    :attr:`hint_text` a :class:`~kivy.properties.AliasProperty` and defaults
     to ''.
     '''
 


Test patch:
Repository: kivy/kivy

Issue:
RstDocument error
@akshayaurora spotted an error which appears right after Kivy Catalog is started.
It was introduced by https://github.com/kivy/kivy/pull/4055.

![untitled-1](https://cloud.githubusercontent.com/assets/7513068/14455028/152c765a-00a6-11e6-8376-25f5e8a19f41.png)



Discussion:
@dessant seems like the word-wrapping feature has some bugs with creating newlines. I'd like to look into this in a day or two. 

Btw, how did you trace it back to that PR? I couldn't find any direct link, except for building an older commit on which it works.

@udiboy1209, I was suspecting TextInput changes because CodeInput is subclassed from it, and I've tested commits from the module's [commit history](https://github.com/kivy/kivy/commits/master/kivy/uix/textinput.py) until I've seen that the [pr commit](https://github.com/kivy/kivy/commit/fbafea19d3b975d823c74319a2eea25c6846a621) breaks, while the pr's [parent commit](https://github.com/kivy/kivy/commit/e82ef10821c00037c321b949ebe7cde932cff477) works.

@dessant I just tested this with a simple TextInput. Same bug occurs ie. The two newlines between `1.4` and `RstDocument` are removed. I will look into this later today.


Resolving patch:
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -2204,8 +2204,8 @@ def _split_smart(self, text):
                 while w > width:
                     split_pos, split_width = self._split_word(word, width)
                     lines_append(word[:split_pos])
-                    lines_flags_append(FL_IS_WORDBREAK)
-                    flags = 0
+                    lines_flags_append(flags)
+                    flags = FL_IS_WORDBREAK
                     word = word[split_pos:]
                     w -= split_width
                 x = w


Test patch:
diff --git a/kivy/tests/test_uix_textinput.py b/kivy/tests/test_uix_textinput.py
--- a/kivy/tests/test_uix_textinput.py
+++ b/kivy/tests/test_uix_textinput.py
@@ -18,3 +18,19 @@ def test_focusable_when_disabled(self):
 
     def on_focused(self, instance, value):
         self.assertTrue(instance.focused, value)
+
+    def test_wordbreak(self):
+        self.test_txt = "Firstlongline\n\nSecondveryverylongline"
+
+        ti = TextInput(width=30, size_hint_x=None)
+        ti.bind(text=self.on_text)
+        ti.text = self.test_txt
+
+    def on_text(self, instance, value):
+        # Check if text is modified while recreating from lines and lines_flags
+        self.assertEquals(instance.text, self.test_txt)
+
+        # Check if wordbreaking is correclty done
+        # If so Secondvery... should start from the 7th line
+        pos_S = self.test_txt.index('S')
+        self.assertEquals(instance.get_cursor_from_index(pos_S), (0,6))
Repository: kivy/kivy

Issue:
Docs - Bottom navigation doesn't work properly
Bottom navigation sends you on the previous and on the next article, but not always.
- https://kivy.org/docs/api-kivy.uix.html (next)
- https://kivy.org/docs/api-kivy.uix.abstractview.html (previous)
- https://kivy.org/docs/api-kivy.uix.anchorlayout.html (this rather skips whole `behaviors` folder though it's in the left navigation)
- https://kivy.org/docs/api-kivy.uix.widget.html (and this pretty much doesn't give a damn at all)

How is the bottom navigation list(?) created and how can I fix it? :hammer: 



Discussion:
**Uix** - uix's next link takes the first folder from sort, so this should be fine probably.

**AbstractView** - `NO DOCUMENTATION` is [taken as `None`](https://github.com/kivy/kivy/blob/master/doc/autobuild.py#L235), therefore it'll take place before the alphabet. So this is clearly not an issue.

**AnchorLayout** - here the navigation skips folder which I don't really know if should be considered an issue or not(depends on preference I think)

**Widget** - there it gets interesting, because it's clearly an issue here. First see these lines:
- https://github.com/kivy/kivy/blob/master/kivy/uix/vkeyboard.py#L2
- https://github.com/kivy/kivy/blob/master/kivy/uix/videoplayer.py#L2
- https://kivy.org/docs/api-kivy.uix.widget.html
- https://github.com/kivy/kivy/blob/master/kivy/uix/rst.py#L2

I suppose that exactly [this line](https://github.com/kivy/kivy/blob/master/doc/autobuild.py#L219) is the problem, because it takes `__doc__` and the first line in `__doc__` is mostly uppercase, but in some cases starts with lowercase. It'd be pointless to search all files if there somehow appeared lowercase and some headers may even need to start with lowercase(rst?).


Resolving patch:
diff --git a/doc/autobuild.py b/doc/autobuild.py
--- a/doc/autobuild.py
+++ b/doc/autobuild.py
@@ -216,7 +216,7 @@ def extract_summary_line(doc):
 
     # search modules
     m = list(modules.keys())
-    m.sort(key=lambda x: extract_summary_line(sys.modules[x].__doc__))
+    m.sort(key=lambda x: extract_summary_line(sys.modules[x].__doc__).upper())
     for module in m:
         packagemodule = module.rsplit('.', 1)[0]
         if packagemodule != package:


Test patch: