From 964b5727cb21746ab91e70a4bfc6cf16e423b51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Bla=C5=A1kovi=C4=87?= Date: Mon, 17 Feb 2025 10:40:59 +0000 Subject: [PATCH] python310/python311: fix failing tests with openssl >= 3.4 --- .../3.10/raise-OSError-for-ERR_LIB_SYS.patch | 28 +++++++++++++++++++ .../interpreters/python/cpython/default.nix | 9 ++++++ 2 files changed, 37 insertions(+) create mode 100644 pkgs/development/interpreters/python/cpython/3.10/raise-OSError-for-ERR_LIB_SYS.patch diff --git a/pkgs/development/interpreters/python/cpython/3.10/raise-OSError-for-ERR_LIB_SYS.patch b/pkgs/development/interpreters/python/cpython/3.10/raise-OSError-for-ERR_LIB_SYS.patch new file mode 100644 index 0000000000000..dd1fe891bf25e --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.10/raise-OSError-for-ERR_LIB_SYS.patch @@ -0,0 +1,28 @@ +diff --git a/Modules/_ssl.c b/Modules/_ssl.c +index e637830..80728d2 100644 +--- a/Modules/_ssl.c ++++ b/Modules/_ssl.c +@@ -656,6 +656,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno) + errstr = "Some I/O error occurred"; + } + } else { ++ if (ERR_GET_LIB(e) == ERR_LIB_SYS) { ++ // A system error is being reported; reason is set to errno ++ errno = ERR_GET_REASON(e); ++ return PyErr_SetFromErrno(PyExc_OSError); ++ } + p = PY_SSL_ERROR_SYSCALL; + } + break; +@@ -681,6 +686,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno) + errstr = "EOF occurred in violation of protocol"; + } + #endif ++ if (ERR_GET_LIB(e) == ERR_LIB_SYS) { ++ // A system error is being reported; reason is set to errno ++ errno = ERR_GET_REASON(e); ++ return PyErr_SetFromErrno(PyExc_OSError); ++ } + break; + } + default: diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index d0fab0f83a667..8a052a55b7daa 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -299,6 +299,15 @@ in with passthru; stdenv.mkDerivation (finalAttrs: { ] ++ optionals (pythonOlder "3.12") [ # https://github.com/python/cpython/issues/90656 ./loongarch-support.patch + # fix failing tests with openssl >= 3.4 + # https://github.com/python/cpython/pull/127361 + ] ++ optionals (pythonAtLeast "3.10" && pythonOlder "3.11") [ + ./3.10/raise-OSError-for-ERR_LIB_SYS.patch + ] ++ optionals (pythonAtLeast "3.11" && pythonOlder "3.12") [ + (fetchpatch { + url = "https://github.com/python/cpython/commit/f4b31edf2d9d72878dab1f66a36913b5bcc848ec.patch"; + sha256 = "sha256-w7zZMp0yqyi4h5oG8sK4z9BwNEkqg4Ar+en3nlWcxh0="; + }) ] ++ optionals (pythonAtLeast "3.11" && pythonOlder "3.13") [ # backport fix for https://github.com/python/cpython/issues/95855 ./platform-triplet-detection.patch