unsupported operand type(s) for +=: 'NoneType' and 'list' in invalidate_draw in chaco
- Dominant language
- Python
- Stars
- 305
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
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: , 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))
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.