>>> import ssl, _ssl
>>> ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
>>> descr = _ssl._SSLContext.__dict__['_msg_callback']
>>> descr.__set__(ctx, lambda *args: None)
>>> descr.__delete__(ctx)
Traceback (most recent call last):
...
TypeError: not a callable object
>>> print(descr.__get__(ctx))
None
Bug report
The setter of
_ssl._SSLContext._msg_callbackclears the current callback before validating the new value, so a rejected assignment or a deletion loses it.Deleting the attribute should raise
AttributeError, like forkeylog_filename(gh-156099) androw_factory(gh-149738), and neither a failed deletion nor a failed assignment should change the value.ssl.SSLContextwraps the attribute in a property which checks the value and has no deleter, so this is only reachable through the C type.Linked PRs