Blame SOURCES/0004-3.0.0-deprecated-func-and-it-isn-t-useful-to-us-in-g.patch

37a582
From 417984a48106626b5f6a62763113c0ed1f741f5b Mon Sep 17 00:00:00 2001
37a582
From: Paul Kehrer <paul.l.kehrer@gmail.com>
37a582
Date: Wed, 30 Jun 2021 06:14:42 -0500
37a582
Subject: [PATCH 4/5] 3.0.0 deprecated func and it isn't useful to us in
37a582
 general (#6148)
37a582
37a582
remove it everywhere and assert on the code/lib/reason
37a582
---
37a582
 src/cryptography/hazmat/bindings/openssl/binding.py | 11 ++++-------
37a582
 tests/hazmat/bindings/test_openssl.py               |  5 ++---
37a582
 2 files changed, 6 insertions(+), 10 deletions(-)
37a582
37a582
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
37a582
index 6dcec26a..f651ab67 100644
37a582
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
37a582
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
37a582
@@ -15,15 +15,14 @@ from cryptography.hazmat.bindings._openssl import ffi, lib
37a582
 from cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES
37a582
 
37a582
 _OpenSSLErrorWithText = collections.namedtuple(
37a582
-    "_OpenSSLErrorWithText", ["code", "lib", "func", "reason", "reason_text"]
37a582
+    "_OpenSSLErrorWithText", ["code", "lib", "reason", "reason_text"]
37a582
 )
37a582
 
37a582
 
37a582
 class _OpenSSLError(object):
37a582
-    def __init__(self, code, lib, func, reason):
37a582
+    def __init__(self, code, lib, reason):
37a582
         self._code = code
37a582
         self._lib = lib
37a582
-        self._func = func
37a582
         self._reason = reason
37a582
 
37a582
     def _lib_reason_match(self, lib, reason):
37a582
@@ -31,7 +30,6 @@ class _OpenSSLError(object):
37a582
 
37a582
     code = utils.read_only_property("_code")
37a582
     lib = utils.read_only_property("_lib")
37a582
-    func = utils.read_only_property("_func")
37a582
     reason = utils.read_only_property("_reason")
37a582
 
37a582
 
37a582
@@ -43,10 +41,9 @@ def _consume_errors(lib):
37a582
             break
37a582
 
37a582
         err_lib = lib.ERR_GET_LIB(code)
37a582
-        err_func = lib.ERR_GET_FUNC(code)
37a582
         err_reason = lib.ERR_GET_REASON(code)
37a582
 
37a582
-        errors.append(_OpenSSLError(code, err_lib, err_func, err_reason))
37a582
+        errors.append(_OpenSSLError(code, err_lib, err_reason))
37a582
 
37a582
     return errors
37a582
 
37a582
@@ -60,7 +57,7 @@ def _errors_with_text(errors):
37a582
 
37a582
         errors_with_text.append(
37a582
             _OpenSSLErrorWithText(
37a582
-                err.code, err.lib, err.func, err.reason, err_text_reason
37a582
+                err.code, err.lib, err.reason, err_text_reason
37a582
             )
37a582
         )
37a582
 
37a582
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
37a582
index 4d1e3b55..1d9b87ba 100644
37a582
--- a/tests/hazmat/bindings/test_openssl.py
37a582
+++ b/tests/hazmat/bindings/test_openssl.py
37a582
@@ -91,11 +91,10 @@ class TestOpenSSL(object):
37a582
             _openssl_assert(b.lib, False)
37a582
 
37a582
         error = exc_info.value.err_code[0]
37a582
-        # As of 3.0.0 OpenSSL sets func codes to 0, so the combined
37a582
-        # code is a different value
37a582
+        # As of 3.0.0 OpenSSL no longer sets func codes (which we now also
37a582
+        # ignore), so the combined code is a different value
37a582
         assert error.code in (101183626, 50331786)
37a582
         assert error.lib == b.lib.ERR_LIB_EVP
37a582
-        assert error.func == b.lib.EVP_F_EVP_ENCRYPTFINAL_EX
37a582
         assert error.reason == b.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH
37a582
         assert b"data not multiple of block length" in error.reason_text
37a582
 
37a582
-- 
37a582
2.31.1
37a582