Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bd305e49
Commit
bd305e49
authored
Jun 14, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #22636: Merge ctypes.util from 3.5
parents
ed80db57
e1b3431c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
19 deletions
+35
-19
Lib/ctypes/util.py
Lib/ctypes/util.py
+35
-19
No files found.
Lib/ctypes/util.py
View file @
bd305e49
...
...
@@ -115,10 +115,13 @@ elif os.name == "posix":
env
=
dict
(
os
.
environ
)
env
[
'LC_ALL'
]
=
'C'
env
[
'LANG'
]
=
'C'
proc
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
)
try
:
proc
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
)
except
OSError
:
# E.g. bad executable
return
None
with
proc
:
trace
=
proc
.
stdout
.
read
()
finally
:
...
...
@@ -140,9 +143,12 @@ elif os.name == "posix":
if
not
f
:
return
None
proc
=
subprocess
.
Popen
((
"/usr/ccs/bin/dump"
,
"-Lpv"
,
f
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
DEVNULL
)
try
:
proc
=
subprocess
.
Popen
((
"/usr/ccs/bin/dump"
,
"-Lpv"
,
f
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
DEVNULL
)
except
OSError
:
# E.g. command not found
return
None
with
proc
:
data
=
proc
.
stdout
.
read
()
res
=
re
.
search
(
br'\
[.*
\]\
sSONAME
\s+([^\
s]+)
', data)
...
...
@@ -159,9 +165,12 @@ elif os.name == "posix":
# objdump is not available, give up
return None
proc = subprocess.Popen((objdump, '
-
p
', '
-
j
', '
.
dynamic
', f),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
try:
proc = subprocess.Popen((objdump, '
-
p
', '
-
j
', '
.
dynamic
', f),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
except OSError: # E.g. bad executable
return None
with proc:
dump = proc.stdout.read()
res = re.search(br'
\
sSONAME
\
s
+
([
^
\
s
]
+
)
', dump)
...
...
@@ -187,11 +196,15 @@ elif os.name == "posix":
expr = r'
:
-
l
%
s
\
.
\
S
+
=>
\
S
*/
(
lib
%
s
\
.
\
S
+
)
' % (ename, ename)
expr = os.fsencode(expr)
proc = subprocess.Popen(('
/
sbin
/
ldconfig
', '
-
r'),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
with proc:
data = proc.stdout.read()
try:
proc = subprocess.Popen(('
/
sbin
/
ldconfig
', '
-
r'),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
except OSError: # E.g. command not found
data = b''
else:
with proc:
data = proc.stdout.read()
res = re.findall(expr, data)
if not res:
...
...
@@ -214,10 +227,13 @@ elif os.name == "posix":
args = ('
/
usr
/
bin
/
crle
',)
paths = None
proc = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
env=env)
try:
proc = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
env=env)
except OSError: # E.g. bad executable
return None
with proc:
for line in proc.stdout:
line = line.strip()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment