schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.2k stars 281 forks source link

tried to multi-delete selections, received traceback #255

Closed carter-canedy closed 2 years ago

carter-canedy commented 2 years ago

Not sure if this is intended behavior, but I just tried to delete multiple selection objects using "delete obj1, obj2" syntax. I received this traceback:

Traceback (most recent call last):
  File "C:\ProgramData\PyMOL\lib\site-packages\pymol\commanding.py", line 525, in delete
    _self.lock(_self)
AttributeError: 'str' object has no attribute 'lock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\PyMOL\lib\site-packages\pymol\commanding.py", line 528, in delete
    _self.unlock(r,_self)
AttributeError: 'str' object has no attribute 'unlock'

I realize that my syntax (specifically the comma) was what induced the exception, but I figured that an unhandled exception might be worth reporting

speleo3 commented 2 years ago

This would be an easy fix by making the _self argument keyword-only.

--- a/modules/pymol/commanding.py
+++ b/modules/pymol/commanding.py
@@ -493,7 +493,7 @@ PYMOL API
                 _self.unlock(-1,_self=_self)
         return None

-    def delete(name,_self=cmd):
+    def delete(name, *, _self=cmd):
         '''
 DESCRIPTION