[Biopython-dev] [Bug 2967] AbstractCommandline silently accepts invalid parameter options
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Wed Dec 9 10:46:11 UTC 2009
http://bugzilla.open-bio.org/show_bug.cgi?id=2967
------- Comment #2 from biopython-bugzilla at maubp.freeserve.co.uk 2009-12-09 05:46 EST -------
(In reply to comment #0)
> While investigating Bug 2996 I noticed that AbstractCommandline was silently
> accepting invalid parameter options when passed by setting attributes. For
> example:
>
> cline = Primer3Commandline(bogus=True)
> cline.sequence = filename
>
> raises the appropriate ValueError, as the parameter name 'bogus' is being
> compared to the self.parameters list when setting, and is found not to be
> valid. However, the following code:
>
> cline = Primer3Commandline()
> cline.sequence = filename
> cline.bogus = True # Invalid argument not flagged up
> cline.sequnce = True # Mistyped argument not flagged up
>
>
> silently sets the invalid cline.bogus and cline.sequnce attributes without
> warning. Parameters set via attribute are not validated with the
> setter/getters defined for the properties in AbstractCommandline.__init__
> This could (did!) lead the user to think that parameters are set when they
> are not, under at least two circumstances:
>
> 1) Typos in the parameter name
> 2) Using a parameter unsupported by the interface
This is normal Python object behaviour - you can add any "property" like this
at run time,
>>> class Dummy(object) :
... pass
...
>>> d = Dummy()
>>> d.name = "Fred"
>>> dir(d)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__weakref__', 'name']
>>> d.name
'Fred'
We might still be able to block this via __setattr__, this needs some
experimentation.
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list