prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  SDL2 - crash on loading asyncimage loading gif?
  relevant log:
  
  Traceback (most recent call last):
    File "/home/chozabu/git/KivEntEd/main.py", line 1289, in <module>
      KivEntEd().run()
    File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 825, in run
      runTouchApp()
    File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 484, in runTouchApp
      EventLoop.window.mainloop()
    File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 364, in mainloop
      self._mainloop()
    File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 268, in _mainloop
      EventLoop.idle()
    File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 324, in idle
      Clock.tick()
    File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 482, in tick
      self._process_events()
    File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 614, in _process_events
      event.tick(self._last_tick, remove)
    File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 373, in tick
      ret = callback(self._dt)
    File "/home/chozabu/git/KivEntEd/ui_elements.py", line 121, in initUI
      self.screenShot.source = serverURL+"/downloadSS?fullname="+self.info['filename']+".png"
    File "kivy/properties.pyx", line 377, in kivy.properties.Property.__set__ (kivy/properties.c:4346)
    File "kivy/properties.pyx", line 409, in kivy.properties.Property.set (kivy/properties.c:4861)
    File "kivy/properties.pyx", line 460, in kivy.properties.Property.dispatch (kivy/properties.c:5437)
    File "kivy/_event.pyx", line 1046, in kivy._event.EventObservers.dispatch (kivy/_event.c:10980)
    File "/usr/local/lib/python2.7/dist-packages/kivy/uix/image.py", line 327, in _load_source
      anim_delay=self.anim_delay)
    File "/usr/local/lib/python2.7/dist-packages/kivy/loader.py", line 432, in image
      client = ProxyImage(self.loading_image,
    File "/usr/local/lib/python2.7/dist-packages/kivy/loader.py", line 163, in _get_loading_image
      self._loading_image = ImageLoader.load(filename=loading_png_fn)
    File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/__init__.py", line 385, in load
      im = loader(filename, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/**init**.py", line 164, in **init**
      self._data = self.load(filename)
    File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/img_sdl2.py", line 34, in load
      raise Exception('SDL2: Unable to load image')
  Exception: SDL2: Unable to load image
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kivy/core/image/img_sdl2.py`
  Content:
  ```
  1 '''
  2 SDL2 image loader
  3 =================
  4 '''
  5 
  6 __all__ = ('ImageLoaderSDL2', )
  7 
  8 from kivy.compat import PY2
  9 from kivy.logger import Logger
  10 from kivy.core.image import ImageLoaderBase, ImageData, ImageLoader
  11 from kivy.core.image import _img_sdl2
  12 
  13 
  14 class ImageLoaderSDL2(ImageLoaderBase):
  15     '''Image loader based on the PIL library'''
  16 
  17     def _ensure_ext(self):
  18         _img_sdl2.init()
  19 
  20     @staticmethod
  21     def extensions():
  22         '''Return accepted extensions for this loader'''
  23         return ('bmp', 'gif', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',
  24                 'webp', 'xcf', 'xpm', 'xv')
  25 
  26     @staticmethod
  27     def can_save():
  28         return True
  29 
  30     def load(self, filename):
  31         info = _img_sdl2.load(filename)
  32         if not info:
  33             Logger.warning('Image: Unable to load image <%s>' % filename)
  34             raise Exception('SDL2: Unable to load image')
  35 
  36         w, h, fmt, pixels, rowlength = info
  37 
  38         # update internals
  39         self.filename = filename
  40         return [ImageData(
  41             w, h, fmt, pixels, source=filename,
  42             rowlength=rowlength)]
  43 
  44     @staticmethod
  45     def save(filename, width, height, fmt, pixels, flipped):
  46         # TODO implement the save for sdl2
  47         #surface = SDL2.image.fromstring(
  48         #        pixels, (width, height), fmt.upper(), False)
  49         #SDL2.image.save(surface, filename)
  50         _img_sdl2.save(filename, width, height, fmt, pixels, flipped)
  51         return True
  52 
  53 
  54 # register
  55 ImageLoader.register(ImageLoaderSDL2)
  56
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/kivy/core/image/img_sdl2.py b/kivy/core/image/img_sdl2.py
  --- a/kivy/core/image/img_sdl2.py
  +++ b/kivy/core/image/img_sdl2.py
  @@ -20,7 +20,7 @@
       @staticmethod
       def extensions():
           '''Return accepted extensions for this loader'''
  -        return ('bmp', 'gif', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',
  +        return ('bmp', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',
                   'webp', 'xcf', 'xpm', 'xv')
   
       @staticmethod
  @@ -43,10 +43,6 @@
   
       @staticmethod
       def save(filename, width, height, fmt, pixels, flipped):
  -        # TODO implement the save for sdl2
  -        #surface = SDL2.image.fromstring(
  -        #        pixels, (width, height), fmt.upper(), False)
  -        #SDL2.image.save(surface, filename)
           _img_sdl2.save(filename, width, height, fmt, pixels, flipped)
           return True
  
verification_info: {"golden_diff": "diff --git a/kivy/core/image/img_sdl2.py b/kivy/core/image/img_sdl2.py\n--- a/kivy/core/image/img_sdl2.py\n+++ b/kivy/core/image/img_sdl2.py\n@@ -20,7 +20,7 @@\n     @staticmethod\n     def extensions():\n         '''Return accepted extensions for this loader'''\n-        return ('bmp', 'gif', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',\n+        return ('bmp', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',\n                 'webp', 'xcf', 'xpm', 'xv')\n \n     @staticmethod\n@@ -43,10 +43,6 @@\n \n     @staticmethod\n     def save(filename, width, height, fmt, pixels, flipped):\n-        # TODO implement the save for sdl2\n-        #surface = SDL2.image.fromstring(\n-        #        pixels, (width, height), fmt.upper(), False)\n-        #SDL2.image.save(surface, filename)\n         _img_sdl2.save(filename, width, height, fmt, pixels, flipped)\n         return True\n", "issue": "SDL2 - crash on loading asyncimage loading gif?\nrelevant log:\n\nTraceback (most recent call last):\n  File \"/home/chozabu/git/KivEntEd/main.py\", line 1289, in <module>\n    KivEntEd().run()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/app.py\", line 825, in run\n    runTouchApp()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/base.py\", line 484, in runTouchApp\n    EventLoop.window.mainloop()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py\", line 364, in mainloop\n    self._mainloop()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py\", line 268, in _mainloop\n    EventLoop.idle()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/base.py\", line 324, in idle\n    Clock.tick()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/clock.py\", line 482, in tick\n    self._process_events()\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/clock.py\", line 614, in _process_events\n    event.tick(self._last_tick, remove)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/clock.py\", line 373, in tick\n    ret = callback(self._dt)\n  File \"/home/chozabu/git/KivEntEd/ui_elements.py\", line 121, in initUI\n    self.screenShot.source = serverURL+\"/downloadSS?fullname=\"+self.info['filename']+\".png\"\n  File \"kivy/properties.pyx\", line 377, in kivy.properties.Property.__set__ (kivy/properties.c:4346)\n  File \"kivy/properties.pyx\", line 409, in kivy.properties.Property.set (kivy/properties.c:4861)\n  File \"kivy/properties.pyx\", line 460, in kivy.properties.Property.dispatch (kivy/properties.c:5437)\n  File \"kivy/_event.pyx\", line 1046, in kivy._event.EventObservers.dispatch (kivy/_event.c:10980)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/uix/image.py\", line 327, in _load_source\n    anim_delay=self.anim_delay)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/loader.py\", line 432, in image\n    client = ProxyImage(self.loading_image,\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/loader.py\", line 163, in _get_loading_image\n    self._loading_image = ImageLoader.load(filename=loading_png_fn)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/core/image/__init__.py\", line 385, in load\n    im = loader(filename, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/core/image/**init**.py\", line 164, in **init**\n    self._data = self.load(filename)\n  File \"/usr/local/lib/python2.7/dist-packages/kivy/core/image/img_sdl2.py\", line 34, in load\n    raise Exception('SDL2: Unable to load image')\nException: SDL2: Unable to load image\n\n", "before_files": [{"content": "'''\nSDL2 image loader\n=================\n'''\n\n__all__ = ('ImageLoaderSDL2', )\n\nfrom kivy.compat import PY2\nfrom kivy.logger import Logger\nfrom kivy.core.image import ImageLoaderBase, ImageData, ImageLoader\nfrom kivy.core.image import _img_sdl2\n\n\nclass ImageLoaderSDL2(ImageLoaderBase):\n    '''Image loader based on the PIL library'''\n\n    def _ensure_ext(self):\n        _img_sdl2.init()\n\n    @staticmethod\n    def extensions():\n        '''Return accepted extensions for this loader'''\n        return ('bmp', 'gif', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',\n                'webp', 'xcf', 'xpm', 'xv')\n\n    @staticmethod\n    def can_save():\n        return True\n\n    def load(self, filename):\n        info = _img_sdl2.load(filename)\n        if not info:\n            Logger.warning('Image: Unable to load image <%s>' % filename)\n            raise Exception('SDL2: Unable to load image')\n\n        w, h, fmt, pixels, rowlength = info\n\n        # update internals\n        self.filename = filename\n        return [ImageData(\n            w, h, fmt, pixels, source=filename,\n            rowlength=rowlength)]\n\n    @staticmethod\n    def save(filename, width, height, fmt, pixels, flipped):\n        # TODO implement the save for sdl2\n        #surface = SDL2.image.fromstring(\n        #        pixels, (width, height), fmt.upper(), False)\n        #SDL2.image.save(surface, filename)\n        _img_sdl2.save(filename, width, height, fmt, pixels, flipped)\n        return True\n\n\n# register\nImageLoader.register(ImageLoaderSDL2)\n", "path": "kivy/core/image/img_sdl2.py"}], "after_files": [{"content": "'''\nSDL2 image loader\n=================\n'''\n\n__all__ = ('ImageLoaderSDL2', )\n\nfrom kivy.compat import PY2\nfrom kivy.logger import Logger\nfrom kivy.core.image import ImageLoaderBase, ImageData, ImageLoader\nfrom kivy.core.image import _img_sdl2\n\n\nclass ImageLoaderSDL2(ImageLoaderBase):\n    '''Image loader based on the PIL library'''\n\n    def _ensure_ext(self):\n        _img_sdl2.init()\n\n    @staticmethod\n    def extensions():\n        '''Return accepted extensions for this loader'''\n        return ('bmp', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',\n                'webp', 'xcf', 'xpm', 'xv')\n\n    @staticmethod\n    def can_save():\n        return True\n\n    def load(self, filename):\n        info = _img_sdl2.load(filename)\n        if not info:\n            Logger.warning('Image: Unable to load image <%s>' % filename)\n            raise Exception('SDL2: Unable to load image')\n\n        w, h, fmt, pixels, rowlength = info\n\n        # update internals\n        self.filename = filename\n        return [ImageData(\n            w, h, fmt, pixels, source=filename,\n            rowlength=rowlength)]\n\n    @staticmethod\n    def save(filename, width, height, fmt, pixels, flipped):\n        _img_sdl2.save(filename, width, height, fmt, pixels, flipped)\n        return True\n\n\n# register\nImageLoader.register(ImageLoaderSDL2)\n", "path": "kivy/core/image/img_sdl2.py"}]}