Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported operand type(s) for +=: 'NoneType' and 'list' in invalidate_draw in chaco #8

Open
HelmutFedder opened this issue May 24, 2011 · 1 comment

Comments

@HelmutFedder
Copy link

OS: Windows XP 32, Windows 7 32
EPD: 7.0, 6.3
related issue: memory leak in copy_ticks on linux (to be submitted as next issue)

During refresh / update of a plot, we sometimes get the following error.

self._update_region += damaged_regions

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'

The respective code in AbstractWindow reads:

class AbstractWindow(HasTraits):
...
    def invalidate_draw(self, damaged_regions=None, self_relative=False):
        if damaged_regions is not None and self._update_region is not None:
            self._update_region += damaged_regions
        else:
            self._update_region = None

Thus, the error in principle cannot occur. Now I speculate: is it a race condition? Is there something not thread safe here?

Sometimes the error occurs frequently and crashes the code. It looks like there is also a memory leak.

In the following are the tracebacks with and without memory error.

Without memor error:

2010-09-06 12:45:16,640 - trait_notifiers._log_exception - ERROR - Exception occurred in traits notification handler for object: <enthought.chaco.array_data_source.ArrayDataSource object at 0x0669E9C0>, trait: data_changed, old value: , new value: True Traceback (most recent call last):

File "C:\Python26\lib\site-packages\enthought\traits\trait_notifiers.py", line 481, in rebind_call_0

self.dispatch( getattr( self.object(), self.name ) )

File "C:\Python26\lib\site-packages\enthought\traits\trait_notifiers.py", line 424, in dispatch

handler( *args )

File "C:\Python26\lib\site-packages\enthought\chaco\base_xy_plot.py", line 600, in _either_data_changed

self.invalidate_draw()

File "C:\Python26\lib\site-packages\enthought\enable\component.py", line 549, in invalidate_draw

self.container.invalidate_draw(damaged_regions=damaged_regions, self_relative=True)

File "C:\Python26\lib\site-packages\enthought\enable\component.py", line 552, in invalidate_draw

self._window.invalidate_draw(damaged_regions=damaged_regions, self_relative=True)

File "C:\Python26\lib\site-packages\enthought\enable\abstract_window.py", line 230, in invalidate_draw

self._update_region += damaged_regions

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'

With Memory Error:

MemoryError Traceback (most recent call last)

C:\Python26\lib\site-packages\enthought\enable\abstract_window.pyc in _paint(sel f, event)

348 self.component.do_layout() 349 gc = self._gc

--> 350 self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))

351 352 # damaged_regions = draw_resultdamaged_regions?

C:\Python26\lib\site-packages\enthought\enable\component.pyc in draw(self, gc, v iew_bounds, mode)

423 self.do_layout() 424

--> 425 self._draw(gc, view_bounds, mode)

426 return 427

C:\Python26\lib\site-packages\enthought\enable\component.pyc in _draw(self, gc, view_bounds, mode)

759 else: 760 for layer in self.draw_order:

--> 761 self._dispatch_draw(layer, gc, view_bounds, mode)

762 763 return

C:\Python26\lib\site-packages\enthought\enable\container.pyc in _dispatch_draw(s elf, layer, gc, view_bounds, mode)

324 component._draw(gc, new_bounds, mode) 325 else:

--> 326 component._dispatch_draw(layer, gc, new_bounds, mode)

327 finally: 328 gc.restore_state()

C:\Python26\lib\site-packages\enthought\enable\component.pyc in _dispatch_draw(s elf, layer, gc, view_bounds, mode)

779 handler = getattr(self, "draw" + layer, None) 780 if handler:

--> 781 handler(gc, view_bounds, mode)

782 return 783

C:\Python26\lib\site-packages\enthought\chaco\base_2d_plot.pyc in _draw_image(se lf, gc, view_bounds, mode)

202 Used by the PlotComponent interface. 203 """

--> 204 self._render(gc)

205 return 206

C:\Python26\lib\site-packages\enthought\chaco\cmap_image_plot.pyc in _render(sel f, gc)

87 self._compute_cached_image(self.value.metadata['selectio

n_masks'])

88 else:

---> 89 self._compute_cached_image()

90 ImagePlot._render(self, gc) 91

C:\Python26\lib\site-packages\enthought\chaco\cmap_image_plot.pyc in _compute_ca ched_image(self, selection_masks)

100 if not self._mapped_image_cache_valid: 101 cached_mapped_image = \

--> 102 self.value_mapper.map_screen(self.value.data) * 255

103 if selection_masks is not None: 104 # construct a composite mask

C:\Python26\lib\site-packages\enthought\chaco\color_mapper.pyc in map_screen(sel f, data_array)

256 norm_data = clip((data_array - low) / (high - low), 0.0, 1.0

)

257

--> 258 return self._map(norm_data)

259 260

C:\Python26\lib\site-packages\enthought\chaco\color_mapper.pyc in _map(self, X)

402 403 nanmask = isnan(xa)

--> 404 xa = where(nanmask, 0, (xa * (self.steps-1)).astype(int))

405 rgba = zeros(xa.shape+(4,), float) 406 rgba[...,0] = where(nanmask, 0, take(self._red_lut, xa))

@dpinte
Copy link
Member

dpinte commented Jun 10, 2011

Helmut,

Is this produced with the same frequency as the other bug you reported ? 1ms ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants