--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id E9A1E6DE00EB\r
+ for <notmuch@notmuchmail.org>; Wed, 25 May 2016 14:37:54 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.255\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.255 tagged_above=-999 required=5 tests=[AWL=0.264, \r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id XeoJVzaoPPst for <notmuch@notmuchmail.org>;\r
+ Wed, 25 May 2016 14:37:47 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 14F8B6DE01F7\r
+ for <notmuch@notmuchmail.org>; Wed, 25 May 2016 14:37:47 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 2D7101000DF; Thu, 26 May 2016 00:37:43 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH 2/2] test: test_python: set PYTHONPATH to the python execution\r
+ environment\r
+Date: Thu, 26 May 2016 00:37:41 +0300\r
+Message-Id: <1464212261-26892-2-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.8.2\r
+In-Reply-To: <1464212261-26892-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <1464212261-26892-1-git-send-email-tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 25 May 2016 21:37:55 -0000\r
+\r
+Place PYTHONPATH to the environment when python is executed in a way\r
+that current shell environment is not affected. This also allows adding\r
+the old value of PYTHONPATH to the end of the new value (otherwise it\r
+would have been appended again and again when test_python is called).\r
+\r
+At the same time, use -B option to avoid writing .pyc files to\r
+bindings/python/* (which are not cleared out by distclean).\r
+\r
+Drop the (unused) prefix code which preserved the original stdout of the\r
+python program and opened sys.stdout to OUTPUT. In place of that there\r
+is now note how (debug) information can be printed to original stdout.\r
+---\r
+ test/test-lib.sh | 8 ++++----\r
+ 1 file changed, 4 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index a7e6397c324e..ec2da0b7151c 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1171,10 +1171,10 @@ test_emacs () {\r
+ }\r
+ \r
+ test_python() {\r
+- export PYTHONPATH=$TEST_DIRECTORY/../bindings/python\r
+-\r
+- (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \\r
+- | $NOTMUCH_PYTHON -\r
++ # Note: if there is need to print debug information from python program,\r
++ # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w')\r
++ PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \\r
++ $NOTMUCH_PYTHON -B - > OUTPUT\r
+ }\r
+ \r
+ test_ruby() {\r
+-- \r
+2.8.2\r
+\r