From cab0b445be02665e2acd473a7c223f2293fb5580 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vcunat@gmail.com>
Date: Tue, 21 Feb 2017 17:55:26 +0100
Subject: [PATCH] python-3.4: fixup with glibc-2.25 (/cc #22874)

Upstream won't support it, but let me trick the code into behaving
as if glibc was older.  It seems 3.3 branch should be unaffected.
---
 .../interpreters/python/cpython/3.4/default.nix          | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pkgs/development/interpreters/python/cpython/3.4/default.nix b/pkgs/development/interpreters/python/cpython/3.4/default.nix
index 66bdd2a42270..72419f8e1943 100644
--- a/pkgs/development/interpreters/python/cpython/3.4/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.4/default.nix
@@ -57,7 +57,14 @@ in stdenv.mkDerivation {
 
   postPatch = optionalString (x11Support && (tix != null)) ''
     substituteInPlace "Lib/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
-  '';
+  ''
+    # Avoid picking up getentropy() from glibc >= 2.25, as that would break
+    # on older kernels.  http://bugs.python.org/issue29157
+    + optionalString stdenv.isLinux
+      ''
+        substituteInPlace Python/random.c --replace 'defined(HAVE_GETENTROPY)' '0'
+        cat Python/random.c
+      '';
 
   preConfigure = ''
     for i in /usr /sw /opt /pkg; do	# improve purity