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? 


On Fri, Jun 25, 2021 at 6:30 PM Oscar Benjamin <> wrote:
On Sat, 26 Jun 2021 at 01:23, Eric V. Smith <> 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.

Python-ideas mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct:
Christopher Barker, PhD (Chris)

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