Skip to content

fix gc undeclare#883

Merged
homosapien-lcy merged 2 commits into
mainfrom
gc_undeclare_fix
Apr 7, 2023
Merged

fix gc undeclare#883
homosapien-lcy merged 2 commits into
mainfrom
gc_undeclare_fix

Conversation

@homosapien-lcy
Copy link
Copy Markdown
Contributor

@homosapien-lcy homosapien-lcy commented Apr 4, 2023

Found that the gc (GraphicsContext) is referenced before construction in the line 136. This has caused the test chaco/chaco/examples/demo/simple_polar.py to fail.
The solution is to find the gc in the context. A gc context is actually conveniently included in the *args, thus retrieving that gc as GraphicContext to solve the problem. closes #875

Copy link
Copy Markdown
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add gc as the first argument to the function

Comment thread chaco/plots/polar_line_renderer.py Outdated
def _draw_plot(self, *args, **kw):
"""Draws the 'plot' layer."""
self._gather_points()
gc = args[0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want the gc to be the first argument to the function, make it the first argument to the function!

Doing this is fragile, not self-documenting and will produce confusing error messages if used incorrectly.

@dpinte
Copy link
Copy Markdown
Member

dpinte commented Apr 6, 2023

For reference, the prototype of the _draw_plot method is defined here: https://github.com/enthought/enable/blob/main/enable/component.py#L807. You could even remove the *arg and **kwargs in favour of the ones from the prototype.

@homosapien-lcy homosapien-lcy merged commit 9ffeefb into main Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NameError: name 'gc' is not defined

3 participants