Issue 36583: Do not swallow exceptions in the _ssl module (original) (raw)
Currently some exceptions can be swallowed in the _ssl module. The proposed PR fixes this. Some examples:
Use PyDict_GetItemWithError() instead of PyDict_GetItem(). The latter swallows any exceptions. Although it is very unlikely that an exception be raised here, it may be possible.
Do not overwrite arbitrary exceptions in PyUnicode_FSConverter(), PyUnicode_AsASCIIString() and PyObject_GetBuffer(). MemoryError most likely can be raised in the first two cases. Only expected exceptions (TypeError or UnicodeEncodeError) will now be replaced with a TypeError, and cadata type will be checked before trying to get a buffer or encode.