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

Prevent AttributeError when deleting a partially initialized Plotter #2819

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

adeak
Copy link
Member

@adeak adeak commented Jun 18, 2022

Breaking a Plotter on __init__() led to two errors:

>>> pv.Plotter(potato='invalid')
Exception ignored in: <function BasePlotter.__del__ at 0x7fe0183279d0>
Traceback (most recent call last):
  File "/home/adeak/pyvista/pyvista/plotting/plotting.py", line 4595, in __del__
    self.deep_clean()
  File "/home/adeak/pyvista/pyvista/plotting/plotting.py", line 3348, in deep_clean
    self.disable_picking()
  File "/home/adeak/pyvista/pyvista/plotting/picking.py", line 1160, in disable_picking
    if self._picker is not None:
AttributeError: 'Plotter' object has no attribute '_picker'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'potato'

Guarding against attribute access of self._picker in Plotter.disable_picking() (called during __del__()) fixes this:

>>> pv.Plotter(potato='invalid')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'potato'

@adeak adeak added the bug Uh-oh! Something isn't working as expected. label Jun 18, 2022
@codecov
Copy link

codecov bot commented Jun 19, 2022

Codecov Report

Merging #2819 (f0e7053) into main (ffba268) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2819      +/-   ##
==========================================
+ Coverage   93.95%   94.00%   +0.05%     
==========================================
  Files          76       76              
  Lines       16356    16355       -1     
==========================================
+ Hits        15367    15375       +8     
+ Misses        989      980       -9     

Copy link
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

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

Thanks! I’ve run into this before and it’s nice to have this cleaned up.

LGTM.

@akaszynski akaszynski merged commit 46080bb into pyvista:main Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants