]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100062: Remove error code tables from _ssl and err_names_to_codes (GH-100063)
authorDavid Benjamin <davidben@google.com>
Mon, 3 Apr 2023 22:44:00 +0000 (07:44 +0900)
committerGitHub <noreply@github.com>
Mon, 3 Apr 2023 22:44:00 +0000 (23:44 +0100)
Prior to https://github.com/python/cpython/pull/25300, the
make_ssl_data.py script used various tables, exposed in _ssl, to update
the error list.

After that PR, this is no longer used. Moreover, the err_names_to_codes
map isn't used at all. Clean those up. This gets them out of the way if,
in the future, OpenSSL provides an API to do what the code here is doing
directly. (https://github.com/openssl/openssl/issues/19848)

Modules/_ssl.c
Modules/_ssl.h

index e0351a89e6a1e9a63ccf1a647470566b8be83baf..5f17cd502d4598a997da7a8ccc86cd6802d45b9c 100644 (file)
@@ -5991,9 +5991,6 @@ sslmodule_init_errorcodes(PyObject *module)
     state->err_codes_to_names = PyDict_New();
     if (state->err_codes_to_names == NULL)
         return -1;
-    state->err_names_to_codes = PyDict_New();
-    if (state->err_names_to_codes == NULL)
-        return -1;
     state->lib_codes_to_names = PyDict_New();
     if (state->lib_codes_to_names == NULL)
         return -1;
@@ -6007,8 +6004,6 @@ sslmodule_init_errorcodes(PyObject *module)
             return -1;
         if (PyDict_SetItem(state->err_codes_to_names, key, mnemo))
             return -1;
-        if (PyDict_SetItem(state->err_names_to_codes, mnemo, key))
-            return -1;
         Py_DECREF(key);
         Py_DECREF(mnemo);
         errcode++;
@@ -6028,13 +6023,6 @@ sslmodule_init_errorcodes(PyObject *module)
         libcode++;
     }
 
-    if (PyModule_AddObjectRef(module, "err_codes_to_names", state->err_codes_to_names))
-        return -1;
-    if (PyModule_AddObjectRef(module, "err_names_to_codes", state->err_names_to_codes))
-        return -1;
-    if (PyModule_AddObjectRef(module, "lib_codes_to_names", state->lib_codes_to_names))
-        return -1;
-
     return 0;
 }
 
@@ -6189,7 +6177,6 @@ sslmodule_traverse(PyObject *m, visitproc visit, void *arg)
     Py_VISIT(state->PySSLSyscallErrorObject);
     Py_VISIT(state->PySSLEOFErrorObject);
     Py_VISIT(state->err_codes_to_names);
-    Py_VISIT(state->err_names_to_codes);
     Py_VISIT(state->lib_codes_to_names);
     Py_VISIT(state->Sock_Type);
 
@@ -6214,7 +6201,6 @@ sslmodule_clear(PyObject *m)
     Py_CLEAR(state->PySSLSyscallErrorObject);
     Py_CLEAR(state->PySSLEOFErrorObject);
     Py_CLEAR(state->err_codes_to_names);
-    Py_CLEAR(state->err_names_to_codes);
     Py_CLEAR(state->lib_codes_to_names);
     Py_CLEAR(state->Sock_Type);
     Py_CLEAR(state->str_library);
index d68ccdec5e88c402bdbc84aa7963cc48d39c1640..c1da8b46b536d367d99414d5464619bef6339417 100644 (file)
@@ -25,7 +25,6 @@ typedef struct {
     PyObject *PySSLEOFErrorObject;
     /* Error mappings */
     PyObject *err_codes_to_names;
-    PyObject *err_names_to_codes;
     PyObject *lib_codes_to_names;
     /* socket type from module CAPI */
     PyTypeObject *Sock_Type;