We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
NameError: name 'gc' is not defined
**Problem Description**
NameError: name 'gc' is not defined in chaco/chaco/plots/polar_line_renderer.py

**Reproduction Steps:**
python chaco/examples/demo/simple_polar.py

[Steps to reproduce issue here.]

```python
# Code to reproduce issue here
```

**Expected behavior:**  

[MacOS, python3.8 (EDM)]

**OS, Python version:** [Enter OS name and Python version]


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `chaco/plots/polar_line_renderer.py`
Content:
```
1 # (C) Copyright 2005-2021 Enthought, Inc., Austin, TX
2 # All rights reserved.
3 #
4 # This software is provided without warranty under the terms of the BSD
5 # license included in LICENSE.txt and may be redistributed only under
6 # the conditions described in the aforementioned license. The license
7 # is also available online at http://www.enthought.com/licenses/BSD.txt
8 #
9 # Thanks for using Enthought open source!
10 
11 """ Defines the PolarLineRenderer class.
12 """
13 
14 
15 # Major library imports
16 from numpy import array, cos, empty, pi, sin, transpose
17 
18 # Enthought library imports
19 from enable.api import black_color_trait, LineStyle
20 from traits.api import Float
21 
22 # Local, relative imports
23 from chaco.abstract_plot_renderer import AbstractPlotRenderer
24 
25 
26 class PolarLineRenderer(AbstractPlotRenderer):
27     """A renderer for polar line plots."""
28 
29     # ------------------------------------------------------------------------
30     # Appearance-related traits
31     # ------------------------------------------------------------------------
32 
33     # The color of the origin axis.
34     origin_axis_color_ = (0, 0, 0, 1)
35     # The width of the origin axis.
36     origin_axis_width = 2.0
37     # The origin axis is visible.
38     origin_axis_visible = True
39     # The grid is visible.
40     grid_visible = True
41     # The orientation of the plot is horizontal; for any other value, it is
42     # transposed
43     orientation = "h"
44     # The color of the line.
45     color = black_color_trait
46     # The width of the line.
47     line_width = Float(1.0)
48     # The style of the line.
49     line_style = LineStyle("solid")
50     # The style of the grid lines.
51     grid_style = LineStyle("dot")
52 
53     def _gather_points(self):
54         """
55         Collects the data points that are within the plot bounds and caches them
56         """
57         # This is just a stub for now.  We should really find the lines only
58         # inside the screen range here.
59 
60         x = self.index.get_data()
61         y = self.value.get_data()
62         rad = min(self.width / 2.0, self.height / 2.0)
63         sx = x * rad + self.x + self.width / 2.0
64         sy = y * rad + self.y + self.height / 2.0
65 
66         points = transpose(array((sx, sy)))
67         self._cached_data_pts = points
68         self._cache_valid = True
69 
70     def _data_changed(self):
71         self._cache_valid = False
72 
73     def _update_mappers(self):
74         # Dunno if there is anything else to do here
75         self._cache_valid = False
76 
77     def _render(self, gc, points):
78         """Actually draw the plot."""
79         with gc:
80             gc.set_antialias(True)
81             self._draw_default_axes(gc)
82             self._draw_default_grid(gc)
83             if len(points) > 0:
84                 gc.clip_to_rect(self.x, self.y, self.width, self.height)
85                 gc.set_stroke_color(self.color_)
86                 gc.set_line_width(self.line_width)
87                 gc.set_line_dash(self.line_style_)
88 
89                 gc.begin_path()
90                 gc.lines(points)
91                 gc.stroke_path()
92 
93     def map_screen(self, data_array):
94         """Maps an array of data points into screen space and returns it as
95         an array.
96 
97         Implements the AbstractPlotRenderer interface.
98         """
99 
100         if len(data_array) == 0:
101             return empty(shape=(0, 2))
102         elif len(data_array) == 1:
103             xtmp, ytmp = transpose(data_array)
104             x_ary = xtmp
105             y_ary = ytmp
106         else:
107             x_ary, y_ary = transpose(data_array)
108 
109         sx = self.index_mapper.map_screen(x_ary)
110         sy = self.value_mapper.map_screen(y_ary)
111 
112         if self.orientation == "h":
113             return transpose(array((sx, sy)))
114         else:
115             return transpose(array((sy, sx)))
116 
117     def map_data(self, screen_pt):
118         """Maps a screen space point into the "index" space of the plot.
119 
120         Implements the AbstractPlotRenderer interface.
121         """
122         if self.orientation == "h":
123             x, y = screen_pt
124         else:
125             y, x = screen_pt
126         return array(
127             (self.index_mapper.map_data(x), self.value_mapper.map_data(y))
128         )
129 
130     def _downsample(self):
131         return self.map_screen(self._cached_data_pts)
132 
133     def _draw_plot(self, *args, **kw):
134         """Draws the 'plot' layer."""
135         self._gather_points()
136         self._render(gc, self._cached_data_pts)
137 
138     def _bounds_changed(self, old, new):
139         super()._bounds_changed(old, new)
140         self._update_mappers()
141 
142     def _bounds_items_changed(self, event):
143         super()._bounds_items_changed(event)
144         self._update_mappers()
145 
146     def _draw_default_axes(self, gc):
147         if not self.origin_axis_visible:
148             return
149 
150         with gc:
151             gc.set_stroke_color(self.origin_axis_color_)
152             gc.set_line_width(self.origin_axis_width)
153             gc.set_line_dash(self.grid_style_)
154             x_data, y_data = transpose(self._cached_data_pts)
155             x_center = self.x + self.width / 2.0
156             y_center = self.y + self.height / 2.0
157 
158             for theta in range(12):
159                 r = min(self.width / 2.0, self.height / 2.0)
160                 x = r * cos(theta * pi / 6) + x_center
161                 y = r * sin(theta * pi / 6) + y_center
162                 data_pts = array([[x_center, y_center], [x, y]])
163                 start, end = data_pts
164                 gc.move_to(int(start[0]), int(start[1]))
165                 gc.line_to(int(end[0]), int(end[1]))
166                 gc.stroke_path()
167 
168     def _draw_default_grid(self, gc):
169         if not self.grid_visible:
170             return
171 
172         with gc:
173             gc.set_stroke_color(self.origin_axis_color_)
174             gc.set_line_width(self.origin_axis_width)
175             gc.set_line_dash(self.grid_style_)
176             x_data, y_data = transpose(self._cached_data_pts)
177             x_center = self.x + self.width / 2.0
178             y_center = self.y + self.height / 2.0
179             rad = min(self.width / 2.0, self.height / 2.0)
180             for r_part in range(1, 5):
181                 r = rad * r_part / 4
182                 gc.arc(x_center, y_center, r, 0, 2 * pi)
183                 gc.stroke_path()
184
```
--- 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()

```

diff --git a/chaco/plots/polar_line_renderer.py b/chaco/plots/polar_line_renderer.py
--- a/chaco/plots/polar_line_renderer.py
+++ b/chaco/plots/polar_line_renderer.py
@@ -130,7 +130,7 @@
     def _downsample(self):
         return self.map_screen(self._cached_data_pts)
 
-    def _draw_plot(self, *args, **kw):
+    def _draw_plot(self, gc, *args, **kw):
         """Draws the 'plot' layer."""
         self._gather_points()
         self._render(gc, self._cached_data_pts)

{"golden_diff": "diff --git a/chaco/plots/polar_line_renderer.py b/chaco/plots/polar_line_renderer.py\n--- a/chaco/plots/polar_line_renderer.py\n+++ b/chaco/plots/polar_line_renderer.py\n@@ -130,7 +130,7 @@\n     def _downsample(self):\n         return self.map_screen(self._cached_data_pts)\n \n-    def _draw_plot(self, *args, **kw):\n+    def _draw_plot(self, gc, *args, **kw):\n         \"\"\"Draws the 'plot' layer.\"\"\"\n         self._gather_points()\n         self._render(gc, self._cached_data_pts)\n", "issue": "NameError: name 'gc' is not defined\n**Problem Description**\nNameError: name 'gc' is not defined in chaco/chaco/plots/polar_line_renderer.py\n\n**Reproduction Steps:**\npython chaco/examples/demo/simple_polar.py\n\n[Steps to reproduce issue here.]\n\n```python\n# Code to reproduce issue here\n```\n\n**Expected behavior:**  \n\n[MacOS, python3.8 (EDM)]\n\n**OS, Python version:** [Enter OS name and Python version]\n\n", "before_files": [{"content": "# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX\n# All rights reserved.\n#\n# This software is provided without warranty under the terms of the BSD\n# license included in LICENSE.txt and may be redistributed only under\n# the conditions described in the aforementioned license. The license\n# is also available online at http://www.enthought.com/licenses/BSD.txt\n#\n# Thanks for using Enthought open source!\n\n\"\"\" Defines the PolarLineRenderer class.\n\"\"\"\n\n\n# Major library imports\nfrom numpy import array, cos, empty, pi, sin, transpose\n\n# Enthought library imports\nfrom enable.api import black_color_trait, LineStyle\nfrom traits.api import Float\n\n# Local, relative imports\nfrom chaco.abstract_plot_renderer import AbstractPlotRenderer\n\n\nclass PolarLineRenderer(AbstractPlotRenderer):\n    \"\"\"A renderer for polar line plots.\"\"\"\n\n    # ------------------------------------------------------------------------\n    # Appearance-related traits\n    # ------------------------------------------------------------------------\n\n    # The color of the origin axis.\n    origin_axis_color_ = (0, 0, 0, 1)\n    # The width of the origin axis.\n    origin_axis_width = 2.0\n    # The origin axis is visible.\n    origin_axis_visible = True\n    # The grid is visible.\n    grid_visible = True\n    # The orientation of the plot is horizontal; for any other value, it is\n    # transposed\n    orientation = \"h\"\n    # The color of the line.\n    color = black_color_trait\n    # The width of the line.\n    line_width = Float(1.0)\n    # The style of the line.\n    line_style = LineStyle(\"solid\")\n    # The style of the grid lines.\n    grid_style = LineStyle(\"dot\")\n\n    def _gather_points(self):\n        \"\"\"\n        Collects the data points that are within the plot bounds and caches them\n        \"\"\"\n        # This is just a stub for now.  We should really find the lines only\n        # inside the screen range here.\n\n        x = self.index.get_data()\n        y = self.value.get_data()\n        rad = min(self.width / 2.0, self.height / 2.0)\n        sx = x * rad + self.x + self.width / 2.0\n        sy = y * rad + self.y + self.height / 2.0\n\n        points = transpose(array((sx, sy)))\n        self._cached_data_pts = points\n        self._cache_valid = True\n\n    def _data_changed(self):\n        self._cache_valid = False\n\n    def _update_mappers(self):\n        # Dunno if there is anything else to do here\n        self._cache_valid = False\n\n    def _render(self, gc, points):\n        \"\"\"Actually draw the plot.\"\"\"\n        with gc:\n            gc.set_antialias(True)\n            self._draw_default_axes(gc)\n            self._draw_default_grid(gc)\n            if len(points) > 0:\n                gc.clip_to_rect(self.x, self.y, self.width, self.height)\n                gc.set_stroke_color(self.color_)\n                gc.set_line_width(self.line_width)\n                gc.set_line_dash(self.line_style_)\n\n                gc.begin_path()\n                gc.lines(points)\n                gc.stroke_path()\n\n    def map_screen(self, data_array):\n        \"\"\"Maps an array of data points into screen space and returns it as\n        an array.\n\n        Implements the AbstractPlotRenderer interface.\n        \"\"\"\n\n        if len(data_array) == 0:\n            return empty(shape=(0, 2))\n        elif len(data_array) == 1:\n            xtmp, ytmp = transpose(data_array)\n            x_ary = xtmp\n            y_ary = ytmp\n        else:\n            x_ary, y_ary = transpose(data_array)\n\n        sx = self.index_mapper.map_screen(x_ary)\n        sy = self.value_mapper.map_screen(y_ary)\n\n        if self.orientation == \"h\":\n            return transpose(array((sx, sy)))\n        else:\n            return transpose(array((sy, sx)))\n\n    def map_data(self, screen_pt):\n        \"\"\"Maps a screen space point into the \"index\" space of the plot.\n\n        Implements the AbstractPlotRenderer interface.\n        \"\"\"\n        if self.orientation == \"h\":\n            x, y = screen_pt\n        else:\n            y, x = screen_pt\n        return array(\n            (self.index_mapper.map_data(x), self.value_mapper.map_data(y))\n        )\n\n    def _downsample(self):\n        return self.map_screen(self._cached_data_pts)\n\n    def _draw_plot(self, *args, **kw):\n        \"\"\"Draws the 'plot' layer.\"\"\"\n        self._gather_points()\n        self._render(gc, self._cached_data_pts)\n\n    def _bounds_changed(self, old, new):\n        super()._bounds_changed(old, new)\n        self._update_mappers()\n\n    def _bounds_items_changed(self, event):\n        super()._bounds_items_changed(event)\n        self._update_mappers()\n\n    def _draw_default_axes(self, gc):\n        if not self.origin_axis_visible:\n            return\n\n        with gc:\n            gc.set_stroke_color(self.origin_axis_color_)\n            gc.set_line_width(self.origin_axis_width)\n            gc.set_line_dash(self.grid_style_)\n            x_data, y_data = transpose(self._cached_data_pts)\n            x_center = self.x + self.width / 2.0\n            y_center = self.y + self.height / 2.0\n\n            for theta in range(12):\n                r = min(self.width / 2.0, self.height / 2.0)\n                x = r * cos(theta * pi / 6) + x_center\n                y = r * sin(theta * pi / 6) + y_center\n                data_pts = array([[x_center, y_center], [x, y]])\n                start, end = data_pts\n                gc.move_to(int(start[0]), int(start[1]))\n                gc.line_to(int(end[0]), int(end[1]))\n                gc.stroke_path()\n\n    def _draw_default_grid(self, gc):\n        if not self.grid_visible:\n            return\n\n        with gc:\n            gc.set_stroke_color(self.origin_axis_color_)\n            gc.set_line_width(self.origin_axis_width)\n            gc.set_line_dash(self.grid_style_)\n            x_data, y_data = transpose(self._cached_data_pts)\n            x_center = self.x + self.width / 2.0\n            y_center = self.y + self.height / 2.0\n            rad = min(self.width / 2.0, self.height / 2.0)\n            for r_part in range(1, 5):\n                r = rad * r_part / 4\n                gc.arc(x_center, y_center, r, 0, 2 * pi)\n                gc.stroke_path()\n", "path": "chaco/plots/polar_line_renderer.py"}], "after_files": [{"content": "# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX\n# All rights reserved.\n#\n# This software is provided without warranty under the terms of the BSD\n# license included in LICENSE.txt and may be redistributed only under\n# the conditions described in the aforementioned license. The license\n# is also available online at http://www.enthought.com/licenses/BSD.txt\n#\n# Thanks for using Enthought open source!\n\n\"\"\" Defines the PolarLineRenderer class.\n\"\"\"\n\n\n# Major library imports\nfrom numpy import array, cos, empty, pi, sin, transpose\n\n# Enthought library imports\nfrom enable.api import black_color_trait, LineStyle\nfrom traits.api import Float\n\n# Local, relative imports\nfrom chaco.abstract_plot_renderer import AbstractPlotRenderer\n\n\nclass PolarLineRenderer(AbstractPlotRenderer):\n    \"\"\"A renderer for polar line plots.\"\"\"\n\n    # ------------------------------------------------------------------------\n    # Appearance-related traits\n    # ------------------------------------------------------------------------\n\n    # The color of the origin axis.\n    origin_axis_color_ = (0, 0, 0, 1)\n    # The width of the origin axis.\n    origin_axis_width = 2.0\n    # The origin axis is visible.\n    origin_axis_visible = True\n    # The grid is visible.\n    grid_visible = True\n    # The orientation of the plot is horizontal; for any other value, it is\n    # transposed\n    orientation = \"h\"\n    # The color of the line.\n    color = black_color_trait\n    # The width of the line.\n    line_width = Float(1.0)\n    # The style of the line.\n    line_style = LineStyle(\"solid\")\n    # The style of the grid lines.\n    grid_style = LineStyle(\"dot\")\n\n    def _gather_points(self):\n        \"\"\"\n        Collects the data points that are within the plot bounds and caches them\n        \"\"\"\n        # This is just a stub for now.  We should really find the lines only\n        # inside the screen range here.\n\n        x = self.index.get_data()\n        y = self.value.get_data()\n        rad = min(self.width / 2.0, self.height / 2.0)\n        sx = x * rad + self.x + self.width / 2.0\n        sy = y * rad + self.y + self.height / 2.0\n\n        points = transpose(array((sx, sy)))\n        self._cached_data_pts = points\n        self._cache_valid = True\n\n    def _data_changed(self):\n        self._cache_valid = False\n\n    def _update_mappers(self):\n        # Dunno if there is anything else to do here\n        self._cache_valid = False\n\n    def _render(self, gc, points):\n        \"\"\"Actually draw the plot.\"\"\"\n        with gc:\n            gc.set_antialias(True)\n            self._draw_default_axes(gc)\n            self._draw_default_grid(gc)\n            if len(points) > 0:\n                gc.clip_to_rect(self.x, self.y, self.width, self.height)\n                gc.set_stroke_color(self.color_)\n                gc.set_line_width(self.line_width)\n                gc.set_line_dash(self.line_style_)\n\n                gc.begin_path()\n                gc.lines(points)\n                gc.stroke_path()\n\n    def map_screen(self, data_array):\n        \"\"\"Maps an array of data points into screen space and returns it as\n        an array.\n\n        Implements the AbstractPlotRenderer interface.\n        \"\"\"\n\n        if len(data_array) == 0:\n            return empty(shape=(0, 2))\n        elif len(data_array) == 1:\n            xtmp, ytmp = transpose(data_array)\n            x_ary = xtmp\n            y_ary = ytmp\n        else:\n            x_ary, y_ary = transpose(data_array)\n\n        sx = self.index_mapper.map_screen(x_ary)\n        sy = self.value_mapper.map_screen(y_ary)\n\n        if self.orientation == \"h\":\n            return transpose(array((sx, sy)))\n        else:\n            return transpose(array((sy, sx)))\n\n    def map_data(self, screen_pt):\n        \"\"\"Maps a screen space point into the \"index\" space of the plot.\n\n        Implements the AbstractPlotRenderer interface.\n        \"\"\"\n        if self.orientation == \"h\":\n            x, y = screen_pt\n        else:\n            y, x = screen_pt\n        return array(\n            (self.index_mapper.map_data(x), self.value_mapper.map_data(y))\n        )\n\n    def _downsample(self):\n        return self.map_screen(self._cached_data_pts)\n\n    def _draw_plot(self, gc, *args, **kw):\n        \"\"\"Draws the 'plot' layer.\"\"\"\n        self._gather_points()\n        self._render(gc, self._cached_data_pts)\n\n    def _bounds_changed(self, old, new):\n        super()._bounds_changed(old, new)\n        self._update_mappers()\n\n    def _bounds_items_changed(self, event):\n        super()._bounds_items_changed(event)\n        self._update_mappers()\n\n    def _draw_default_axes(self, gc):\n        if not self.origin_axis_visible:\n            return\n\n        with gc:\n            gc.set_stroke_color(self.origin_axis_color_)\n            gc.set_line_width(self.origin_axis_width)\n            gc.set_line_dash(self.grid_style_)\n            x_data, y_data = transpose(self._cached_data_pts)\n            x_center = self.x + self.width / 2.0\n            y_center = self.y + self.height / 2.0\n\n            for theta in range(12):\n                r = min(self.width / 2.0, self.height / 2.0)\n                x = r * cos(theta * pi / 6) + x_center\n                y = r * sin(theta * pi / 6) + y_center\n                data_pts = array([[x_center, y_center], [x, y]])\n                start, end = data_pts\n                gc.move_to(int(start[0]), int(start[1]))\n                gc.line_to(int(end[0]), int(end[1]))\n                gc.stroke_path()\n\n    def _draw_default_grid(self, gc):\n        if not self.grid_visible:\n            return\n\n        with gc:\n            gc.set_stroke_color(self.origin_axis_color_)\n            gc.set_line_width(self.origin_axis_width)\n            gc.set_line_dash(self.grid_style_)\n            x_data, y_data = transpose(self._cached_data_pts)\n            x_center = self.x + self.width / 2.0\n            y_center = self.y + self.height / 2.0\n            rad = min(self.width / 2.0, self.height / 2.0)\n            for r_part in range(1, 5):\n                r = rad * r_part / 4\n                gc.arc(x_center, y_center, r, 0, 2 * pi)\n                gc.stroke_path()\n", "path": "chaco/plots/polar_line_renderer.py"}]}