1 This patch was developed in-house. It has been submitted upstream: |
1 This patch was developed in-house. It has been submitted upstream: |
2 http://bugs.python.org/issue23287 |
2 http://bugs.python.org/issue23287 |
3 |
3 |
4 --- Python-3.5.2/Lib/ctypes/util.py.~1~ 2016-06-25 14:38:35.000000000 -0700 |
4 --- Python-3.5.3/Lib/ctypes/util.py.~1~ 2016-12-17 12:05:05.000000000 +0000 |
5 +++ Python-3.5.2/Lib/ctypes/util.py 2016-07-08 07:06:45.026306406 -0700 |
5 +++ Python-3.5.3/Lib/ctypes/util.py 2016-12-19 08:44:16.426321564 +0000 |
6 @@ -175,24 +175,11 @@ |
6 @@ -214,34 +214,15 @@ |
7 |
7 |
8 elif sys.platform == "sunos5": |
8 elif sys.platform == "sunos5": |
9 |
9 |
10 - def _findLib_crle(name, is64): |
10 - def _findLib_crle(name, is64): |
11 - if not os.path.exists('/usr/bin/crle'): |
11 - if not os.path.exists('/usr/bin/crle'): |
12 - return None |
12 - return None |
13 - |
|
14 + def _findLib_path(name, is64): |
13 + def _findLib_path(name, is64): |
|
14 |
|
15 env = dict(os.environ) |
|
16 env['LC_ALL'] = 'C' |
|
17 |
15 if is64: |
18 if is64: |
16 - cmd = 'env LC_ALL=C /usr/bin/crle -64 2>/dev/null' |
19 - args = ('/usr/bin/crle', '-64') |
17 + paths = "/lib/64:/usr/lib/64" |
20 + paths = "/lib/64:/usr/lib/64" |
18 else: |
21 else: |
19 - cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null' |
22 - args = ('/usr/bin/crle',) |
20 - |
23 - |
21 - paths = None |
24 - paths = None |
22 - with contextlib.closing(os.popen(cmd)) as f: |
25 - try: |
23 - for line in f.readlines(): |
26 - proc = subprocess.Popen(args, |
|
27 - stdout=subprocess.PIPE, |
|
28 - stderr=subprocess.DEVNULL, |
|
29 - env=env) |
|
30 - except OSError: # E.g. bad executable |
|
31 - return None |
|
32 - with proc: |
|
33 - for line in proc.stdout: |
24 - line = line.strip() |
34 - line = line.strip() |
25 - if line.startswith('Default Library Path (ELF):'): |
35 - if line.startswith(b'Default Library Path (ELF):'): |
26 - paths = line.split()[4] |
36 - paths = os.fsdecode(line).split()[4] |
27 - |
37 - |
28 - if not paths: |
38 - if not paths: |
29 - return None |
39 - return None |
30 + paths = "/lib:/usr/lib" |
40 + paths = "/lib:/usr/lib" |
31 |
41 |
32 for dir in paths.split(":"): |
42 for dir in paths.split(":"): |
33 libfile = os.path.join(dir, "lib%s.so" % name) |
43 libfile = os.path.join(dir, "lib%s.so" % name) |
34 @@ -202,7 +189,7 @@ |
44 @@ -251,7 +227,7 @@ |
35 return None |
45 return None |
36 |
46 |
37 def find_library(name, is64 = False): |
47 def find_library(name, is64 = False): |
38 - return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) |
48 - return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) |
39 + return _get_soname(_findLib_path(name, is64) or _findLib_gcc(name)) |
49 + return _get_soname(_findLib_path(name, is64) or _findLib_gcc(name)) |