Patchwork ssl: resolve symlink before checking for Apple python executable (issue4588)

login
register
mail settings
Submitter Yuya Nishihara
Date April 4, 2015, 7:32 a.m.
Message ID <c65f355d57a2be8f4e9c.1428132749@mimosa>
Download mbox | patch
Permalink /patch/8496/
State Accepted
Commit 241d98d84aed9af404d86e04df6ab4e41fd2225d
Headers show

Comments

Yuya Nishihara - April 4, 2015, 7:32 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1428126978 -32400
#      Sat Apr 04 14:56:18 2015 +0900
# Node ID c65f355d57a2be8f4e9c0ed0ca734ba9cec83c8d
# Parent  4a4018831d2ebc3c9cae9c6613e6a2497b4f0993
ssl: resolve symlink before checking for Apple python executable (issue4588)

test-https.t was broken at 07fafcd4bc74 if /usr/bin/pythonX.Y is used on
Mac OS X.

If python executable is not named as "python", run-tests.py creates a symlink
and hghave uses it. On the other hand, the installed hg executable knows the
real path to the system Python. Therefore, there was an inconsistency that
hghave said it was not an Apple python but hg knew it was.
Augie Fackler - April 4, 2015, 4:02 p.m.
On Apr 4, 2015, at 3:32 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1428126978 -32400
> #      Sat Apr 04 14:56:18 2015 +0900
> # Node ID c65f355d57a2be8f4e9c0ed0ca734ba9cec83c8d
> # Parent  4a4018831d2ebc3c9cae9c6613e6a2497b4f0993
> ssl: resolve symlink before checking for Apple python executable (issue4588)

Queued this, impressive detective work. Thanks!

> 
> test-https.t was broken at 07fafcd4bc74 if /usr/bin/pythonX.Y is used on
> Mac OS X.
> 
> If python executable is not named as "python", run-tests.py creates a symlink
> and hghave uses it. On the other hand, the installed hg executable knows the
> real path to the system Python. Therefore, there was an inconsistency that
> hghave said it was not an Apple python but hg knew it was.
> 
> diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py
> --- a/mercurial/sslutil.py
> +++ b/mercurial/sslutil.py
> @@ -129,9 +129,9 @@ def _plainapplepython():
>       for using system certificate store CAs in addition to the provided
>       cacerts file
>     """
> -    if sys.platform != 'darwin' or util.mainfrozen():
> +    if sys.platform != 'darwin' or util.mainfrozen() or not sys.executable:
>         return False
> -    exe = (sys.executable or '').lower()
> +    exe = os.path.realpath(sys.executable).lower()
>     return (exe.startswith('/usr/bin/python') or
>             exe.startswith('/system/library/frameworks/python.framework/'))
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py
--- a/mercurial/sslutil.py
+++ b/mercurial/sslutil.py
@@ -129,9 +129,9 @@  def _plainapplepython():
       for using system certificate store CAs in addition to the provided
       cacerts file
     """
-    if sys.platform != 'darwin' or util.mainfrozen():
+    if sys.platform != 'darwin' or util.mainfrozen() or not sys.executable:
         return False
-    exe = (sys.executable or '').lower()
+    exe = os.path.realpath(sys.executable).lower()
     return (exe.startswith('/usr/bin/python') or
             exe.startswith('/system/library/frameworks/python.framework/'))