As has been  said, allowing arbitrary attribute assignments is standard Python. 

But given the security implications, it does make sense to have more validation in this case.

If backward incompatibility is not an option how about raising a Warning? 

-CHB 


On Fri, Jun 25, 2021 at 6:30 PM Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
On Sat, 26 Jun 2021 at 01:23, Eric V. Smith <eric@trueblade.com> wrote:
>
> On 6/25/2021 8:09 PM, Steven D'Aprano wrote:
> > Hi Thomas,
> >
> > On Fri, Jun 25, 2021 at 09:06:58AM -0000, Thomas Grainger wrote:
> >
> >> I'd like invalid attribute assignment to be prevented at runtime
> > Are you making a specific request for ssl context objects, or a general
> > language-wide request that applies to all objects?
>
> It seems like many of the suggestions are SSLContext specific. I don't
> think we should be adding __slots__ or otherwise redefining the
> interface to that object. Isn't this a general "problem" in python,
> that's always been present? Why are we trying to address the problem
> with this specific object? I suggest doing nothing, or else thinking big
> and solve the general problem, if in fact it needs solving.

I would say that the general problem highlighted here is that
assigning attributes is a bad API. Given that this is already how the
SSL module works, a backwards compatible way to move forwards could be
defining a new class with a more typical interface and better
verification of inputs etc.


Oscar
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KKBYSXKEFRQ5QVWLGGZWUX475AWLRPFU/
Code of Conduct: http://python.org/psf/codeofconduct/
--
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython