mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #22636: Merge ctypes.util from 3.5
This commit is contained in:
commit
bd305e497f
1 changed files with 35 additions and 19 deletions
|
@ -115,10 +115,13 @@ elif os.name == "posix":
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env['LC_ALL'] = 'C'
|
env['LC_ALL'] = 'C'
|
||||||
env['LANG'] = 'C'
|
env['LANG'] = 'C'
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(args,
|
proc = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
env=env)
|
env=env)
|
||||||
|
except OSError: # E.g. bad executable
|
||||||
|
return None
|
||||||
with proc:
|
with proc:
|
||||||
trace = proc.stdout.read()
|
trace = proc.stdout.read()
|
||||||
finally:
|
finally:
|
||||||
|
@ -140,9 +143,12 @@ elif os.name == "posix":
|
||||||
if not f:
|
if not f:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(("/usr/ccs/bin/dump", "-Lpv", f),
|
proc = subprocess.Popen(("/usr/ccs/bin/dump", "-Lpv", f),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
except OSError: # E.g. command not found
|
||||||
|
return None
|
||||||
with proc:
|
with proc:
|
||||||
data = proc.stdout.read()
|
data = proc.stdout.read()
|
||||||
res = re.search(br'\[.*\]\sSONAME\s+([^\s]+)', data)
|
res = re.search(br'\[.*\]\sSONAME\s+([^\s]+)', data)
|
||||||
|
@ -159,9 +165,12 @@ elif os.name == "posix":
|
||||||
# objdump is not available, give up
|
# objdump is not available, give up
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
proc = subprocess.Popen((objdump, '-p', '-j', '.dynamic', f),
|
proc = subprocess.Popen((objdump, '-p', '-j', '.dynamic', f),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
except OSError: # E.g. bad executable
|
||||||
|
return None
|
||||||
with proc:
|
with proc:
|
||||||
dump = proc.stdout.read()
|
dump = proc.stdout.read()
|
||||||
res = re.search(br'\sSONAME\s+([^\s]+)', dump)
|
res = re.search(br'\sSONAME\s+([^\s]+)', dump)
|
||||||
|
@ -187,9 +196,13 @@ elif os.name == "posix":
|
||||||
expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
|
expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
|
||||||
expr = os.fsencode(expr)
|
expr = os.fsencode(expr)
|
||||||
|
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(('/sbin/ldconfig', '-r'),
|
proc = subprocess.Popen(('/sbin/ldconfig', '-r'),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
except OSError: # E.g. command not found
|
||||||
|
data = b''
|
||||||
|
else:
|
||||||
with proc:
|
with proc:
|
||||||
data = proc.stdout.read()
|
data = proc.stdout.read()
|
||||||
|
|
||||||
|
@ -214,10 +227,13 @@ elif os.name == "posix":
|
||||||
args = ('/usr/bin/crle',)
|
args = ('/usr/bin/crle',)
|
||||||
|
|
||||||
paths = None
|
paths = None
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(args,
|
proc = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
env=env)
|
env=env)
|
||||||
|
except OSError: # E.g. bad executable
|
||||||
|
return None
|
||||||
with proc:
|
with proc:
|
||||||
for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue