prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Demo world_map.py does not work on python 2
  **Problem Description**
  urllib.request deprecated in Python 2
  **Reproduction Steps:**
  Run world_map.py
  
  **Expected behavior:**
  
  Traceback (most recent call last):
    File "world_map.py", line 15, in <module>
      import urllib.request, urllib.parse, urllib.error
  ImportError: No module named request
  
  **OS, Python version:** [Enter OS name and Python version]
  OSX, Python 2.7
  
  xref: #385
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/demo/world_map.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 """
  3 Displays a world map with locations plotted on top. Locations are expected to
  4 be tuples of latitude, longitude where West and South are expressed as
  5 negative values.
  6  - Mousewheel up and down zooms the plot in and out.
  7  - Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular
  8    region to zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow
  9    and alt-right-arrow moves you forwards and backwards through the "zoom
  10    history".
  11 """
  12 
  13 # Standard library imports
  14 import os.path
  15 import urllib.request, urllib.parse, urllib.error
  16 
  17 # Major library imports
  18 import numpy
  19 
  20 # ETS imports
  21 from chaco.api import Plot, ArrayPlotData, ImageData
  22 from chaco.tools.api import ZoomTool
  23 from enable.component_editor import ComponentEditor
  24 from traits.api import HasTraits, Instance, Str
  25 from traitsui.api import Item, View
  26 
  27 class WorldMapPlot(HasTraits):
  28 
  29     ### Public Traits ##########################################################
  30 
  31     # The plot which will be displayed
  32     plot = Instance(Plot)
  33 
  34     # The URL which points to the world map image to be downloaded
  35     image_url = Str("http://eoimages.gsfc.nasa.gov/ve//2433/land_shallow_topo_2048.jpg")
  36 
  37 
  38     ### Private Traits #########################################################
  39 
  40     # The path to where the image exists on the filesystem
  41     image_path = Str()
  42 
  43     # The view
  44     traits_view = View(Item('plot', editor=ComponentEditor(),
  45                             width=800, height=400, show_label=False),
  46                        resizable=True)
  47 
  48     #---------------------------------------------------------------------------
  49     # Public interface
  50     #---------------------------------------------------------------------------
  51 
  52     def __init__(self, **kw):
  53         super(WorldMapPlot, self).__init__(**kw)
  54 
  55         self._download_map_image()
  56         image = ImageData.fromfile(self.image_path)
  57 
  58         # For now, the locations are hardcoded, though this can be changed
  59         # eassily to take command line args, read from a file, or by other
  60         # means
  61         austin_loc = (30.16, -97.44)
  62 
  63         locations_x = numpy.array([austin_loc[1]])
  64         locations_y = numpy.array([austin_loc[0]])
  65 
  66         # transform each of the locations to the image data space, including
  67         # moving the origin from bottom left to top left
  68         locations_x = (locations_x + 180) * image.data.shape[1]/360
  69         locations_y = (locations_y*-1 + 90) * image.data.shape[0]/180
  70 
  71         # Create the plott data, adding the image and the locations
  72         plot_data = ArrayPlotData()
  73         plot_data.set_data("imagedata", image._data)
  74         plot_data.set_data("locations_x", locations_x)
  75         plot_data.set_data("locations_y", locations_y)
  76 
  77         # Create the plot with the origin as top left, which matches
  78         # how the image data is aligned
  79         self.plot = Plot(plot_data, default_origin="top left")
  80         self.plot.img_plot('imagedata')
  81 
  82         # Plot the locations as a scatter plot to be overlayed on top
  83         # of the map
  84         loc_plot = self.plot.plot(('locations_x',  'locations_y'),
  85                                     type='scatter', size=3, color='yellow',
  86                                     marker='dot')[0]
  87 
  88         loc_plot.x_mapper.range.high = image.data.shape[1]
  89         loc_plot.x_mapper.range.low = 0
  90         loc_plot.y_mapper.range.high = image.data.shape[0]
  91         loc_plot.y_mapper.range.low = -0
  92 
  93         # set up any tools, in this case just the zoom tool
  94         zoom = ZoomTool(component=self.plot, tool_mode="box", always_on=False)
  95         self.plot.overlays.append(zoom)
  96 
  97     #---------------------------------------------------------------------------
  98     # Protected interface
  99     #---------------------------------------------------------------------------
  100 
  101     def _download_map_image(self):
  102         """ Downloads a map from the image_url attribute. This is done
  103             primarily to keep the redistributable Chaco package as small
  104             as possible
  105         """
  106         example_dir = os.path.dirname(__file__)
  107         self.image_path = os.path.join(example_dir, 'data',
  108                                         os.path.split(self.image_url)[1])
  109 
  110         if not os.path.exists(self.image_path):
  111             print("Downloading map image")
  112             urllib.request.urlretrieve(self.image_url, self.image_path)
  113 
  114 #===============================================================================
  115 # demo object that is used by the demo.py application.
  116 #===============================================================================
  117 demo = WorldMapPlot()
  118 
  119 if __name__ == "__main__":
  120     demo.configure_traits()
  121
  ```
  --- 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/examples/demo/world_map.py b/examples/demo/world_map.py
  --- a/examples/demo/world_map.py
  +++ b/examples/demo/world_map.py
  @@ -12,7 +12,7 @@
   
   # Standard library imports
   import os.path
  -import urllib.request, urllib.parse, urllib.error
  +from six.moves.urllib import request
   
   # Major library imports
   import numpy
  @@ -109,7 +109,7 @@
   
           if not os.path.exists(self.image_path):
               print("Downloading map image")
  -            urllib.request.urlretrieve(self.image_url, self.image_path)
  +            request.urlretrieve(self.image_url, self.image_path)
   
   #===============================================================================
   # demo object that is used by the demo.py application.
  
verification_info: {"golden_diff": "diff --git a/examples/demo/world_map.py b/examples/demo/world_map.py\n--- a/examples/demo/world_map.py\n+++ b/examples/demo/world_map.py\n@@ -12,7 +12,7 @@\n \n # Standard library imports\n import os.path\n-import urllib.request, urllib.parse, urllib.error\n+from six.moves.urllib import request\n \n # Major library imports\n import numpy\n@@ -109,7 +109,7 @@\n \n         if not os.path.exists(self.image_path):\n             print(\"Downloading map image\")\n-            urllib.request.urlretrieve(self.image_url, self.image_path)\n+            request.urlretrieve(self.image_url, self.image_path)\n \n #===============================================================================\n # demo object that is used by the demo.py application.\n", "issue": "Demo world_map.py does not work on python 2\n**Problem Description**\r\nurllib.request deprecated in Python 2\r\n**Reproduction Steps:**\r\nRun world_map.py\r\n\r\n**Expected behavior:**\r\n\r\nTraceback (most recent call last):\r\n  File \"world_map.py\", line 15, in <module>\r\n    import urllib.request, urllib.parse, urllib.error\r\nImportError: No module named request\r\n\r\n**OS, Python version:** [Enter OS name and Python version]\r\nOSX, Python 2.7\r\n\r\nxref: #385\n", "before_files": [{"content": "#!/usr/bin/env python\n\"\"\"\nDisplays a world map with locations plotted on top. Locations are expected to\nbe tuples of latitude, longitude where West and South are expressed as\nnegative values.\n - Mousewheel up and down zooms the plot in and out.\n - Pressing \"z\" brings up the Zoom Box, and you can click-drag a rectangular\n   region to zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow\n   and alt-right-arrow moves you forwards and backwards through the \"zoom\n   history\".\n\"\"\"\n\n# Standard library imports\nimport os.path\nimport urllib.request, urllib.parse, urllib.error\n\n# Major library imports\nimport numpy\n\n# ETS imports\nfrom chaco.api import Plot, ArrayPlotData, ImageData\nfrom chaco.tools.api import ZoomTool\nfrom enable.component_editor import ComponentEditor\nfrom traits.api import HasTraits, Instance, Str\nfrom traitsui.api import Item, View\n\nclass WorldMapPlot(HasTraits):\n\n    ### Public Traits ##########################################################\n\n    # The plot which will be displayed\n    plot = Instance(Plot)\n\n    # The URL which points to the world map image to be downloaded\n    image_url = Str(\"http://eoimages.gsfc.nasa.gov/ve//2433/land_shallow_topo_2048.jpg\")\n\n\n    ### Private Traits #########################################################\n\n    # The path to where the image exists on the filesystem\n    image_path = Str()\n\n    # The view\n    traits_view = View(Item('plot', editor=ComponentEditor(),\n                            width=800, height=400, show_label=False),\n                       resizable=True)\n\n    #---------------------------------------------------------------------------\n    # Public interface\n    #---------------------------------------------------------------------------\n\n    def __init__(self, **kw):\n        super(WorldMapPlot, self).__init__(**kw)\n\n        self._download_map_image()\n        image = ImageData.fromfile(self.image_path)\n\n        # For now, the locations are hardcoded, though this can be changed\n        # eassily to take command line args, read from a file, or by other\n        # means\n        austin_loc = (30.16, -97.44)\n\n        locations_x = numpy.array([austin_loc[1]])\n        locations_y = numpy.array([austin_loc[0]])\n\n        # transform each of the locations to the image data space, including\n        # moving the origin from bottom left to top left\n        locations_x = (locations_x + 180) * image.data.shape[1]/360\n        locations_y = (locations_y*-1 + 90) * image.data.shape[0]/180\n\n        # Create the plott data, adding the image and the locations\n        plot_data = ArrayPlotData()\n        plot_data.set_data(\"imagedata\", image._data)\n        plot_data.set_data(\"locations_x\", locations_x)\n        plot_data.set_data(\"locations_y\", locations_y)\n\n        # Create the plot with the origin as top left, which matches\n        # how the image data is aligned\n        self.plot = Plot(plot_data, default_origin=\"top left\")\n        self.plot.img_plot('imagedata')\n\n        # Plot the locations as a scatter plot to be overlayed on top\n        # of the map\n        loc_plot = self.plot.plot(('locations_x',  'locations_y'),\n                                    type='scatter', size=3, color='yellow',\n                                    marker='dot')[0]\n\n        loc_plot.x_mapper.range.high = image.data.shape[1]\n        loc_plot.x_mapper.range.low = 0\n        loc_plot.y_mapper.range.high = image.data.shape[0]\n        loc_plot.y_mapper.range.low = -0\n\n        # set up any tools, in this case just the zoom tool\n        zoom = ZoomTool(component=self.plot, tool_mode=\"box\", always_on=False)\n        self.plot.overlays.append(zoom)\n\n    #---------------------------------------------------------------------------\n    # Protected interface\n    #---------------------------------------------------------------------------\n\n    def _download_map_image(self):\n        \"\"\" Downloads a map from the image_url attribute. This is done\n            primarily to keep the redistributable Chaco package as small\n            as possible\n        \"\"\"\n        example_dir = os.path.dirname(__file__)\n        self.image_path = os.path.join(example_dir, 'data',\n                                        os.path.split(self.image_url)[1])\n\n        if not os.path.exists(self.image_path):\n            print(\"Downloading map image\")\n            urllib.request.urlretrieve(self.image_url, self.image_path)\n\n#===============================================================================\n# demo object that is used by the demo.py application.\n#===============================================================================\ndemo = WorldMapPlot()\n\nif __name__ == \"__main__\":\n    demo.configure_traits()\n", "path": "examples/demo/world_map.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\"\"\"\nDisplays a world map with locations plotted on top. Locations are expected to\nbe tuples of latitude, longitude where West and South are expressed as\nnegative values.\n - Mousewheel up and down zooms the plot in and out.\n - Pressing \"z\" brings up the Zoom Box, and you can click-drag a rectangular\n   region to zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow\n   and alt-right-arrow moves you forwards and backwards through the \"zoom\n   history\".\n\"\"\"\n\n# Standard library imports\nimport os.path\nfrom six.moves.urllib import request\n\n# Major library imports\nimport numpy\n\n# ETS imports\nfrom chaco.api import Plot, ArrayPlotData, ImageData\nfrom chaco.tools.api import ZoomTool\nfrom enable.component_editor import ComponentEditor\nfrom traits.api import HasTraits, Instance, Str\nfrom traitsui.api import Item, View\n\nclass WorldMapPlot(HasTraits):\n\n    ### Public Traits ##########################################################\n\n    # The plot which will be displayed\n    plot = Instance(Plot)\n\n    # The URL which points to the world map image to be downloaded\n    image_url = Str(\"http://eoimages.gsfc.nasa.gov/ve//2433/land_shallow_topo_2048.jpg\")\n\n\n    ### Private Traits #########################################################\n\n    # The path to where the image exists on the filesystem\n    image_path = Str()\n\n    # The view\n    traits_view = View(Item('plot', editor=ComponentEditor(),\n                            width=800, height=400, show_label=False),\n                       resizable=True)\n\n    #---------------------------------------------------------------------------\n    # Public interface\n    #---------------------------------------------------------------------------\n\n    def __init__(self, **kw):\n        super(WorldMapPlot, self).__init__(**kw)\n\n        self._download_map_image()\n        image = ImageData.fromfile(self.image_path)\n\n        # For now, the locations are hardcoded, though this can be changed\n        # eassily to take command line args, read from a file, or by other\n        # means\n        austin_loc = (30.16, -97.44)\n\n        locations_x = numpy.array([austin_loc[1]])\n        locations_y = numpy.array([austin_loc[0]])\n\n        # transform each of the locations to the image data space, including\n        # moving the origin from bottom left to top left\n        locations_x = (locations_x + 180) * image.data.shape[1]/360\n        locations_y = (locations_y*-1 + 90) * image.data.shape[0]/180\n\n        # Create the plott data, adding the image and the locations\n        plot_data = ArrayPlotData()\n        plot_data.set_data(\"imagedata\", image._data)\n        plot_data.set_data(\"locations_x\", locations_x)\n        plot_data.set_data(\"locations_y\", locations_y)\n\n        # Create the plot with the origin as top left, which matches\n        # how the image data is aligned\n        self.plot = Plot(plot_data, default_origin=\"top left\")\n        self.plot.img_plot('imagedata')\n\n        # Plot the locations as a scatter plot to be overlayed on top\n        # of the map\n        loc_plot = self.plot.plot(('locations_x',  'locations_y'),\n                                    type='scatter', size=3, color='yellow',\n                                    marker='dot')[0]\n\n        loc_plot.x_mapper.range.high = image.data.shape[1]\n        loc_plot.x_mapper.range.low = 0\n        loc_plot.y_mapper.range.high = image.data.shape[0]\n        loc_plot.y_mapper.range.low = -0\n\n        # set up any tools, in this case just the zoom tool\n        zoom = ZoomTool(component=self.plot, tool_mode=\"box\", always_on=False)\n        self.plot.overlays.append(zoom)\n\n    #---------------------------------------------------------------------------\n    # Protected interface\n    #---------------------------------------------------------------------------\n\n    def _download_map_image(self):\n        \"\"\" Downloads a map from the image_url attribute. This is done\n            primarily to keep the redistributable Chaco package as small\n            as possible\n        \"\"\"\n        example_dir = os.path.dirname(__file__)\n        self.image_path = os.path.join(example_dir, 'data',\n                                        os.path.split(self.image_url)[1])\n\n        if not os.path.exists(self.image_path):\n            print(\"Downloading map image\")\n            request.urlretrieve(self.image_url, self.image_path)\n\n#===============================================================================\n# demo object that is used by the demo.py application.\n#===============================================================================\ndemo = WorldMapPlot()\n\nif __name__ == \"__main__\":\n    demo.configure_traits()\n", "path": "examples/demo/world_map.py"}]}