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
17903837
Commit
17903837
authored
Dec 12, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly close pipes so test_ctypes won't appear to randomly leak
+33 or -33 references. (See discussion in #1597.)
parent
b9d706fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
Lib/ctypes/util.py
Lib/ctypes/util.py
+34
-9
No files found.
Lib/ctypes/util.py
View file @
17903837
...
@@ -50,8 +50,10 @@ elif os.name == "posix":
...
@@ -50,8 +50,10 @@ elif os.name == "posix":
'$CC -Wl,-t -o '
+
ccout
+
' 2>&1 -l'
+
name
'$CC -Wl,-t -o '
+
ccout
+
' 2>&1 -l'
+
name
try
:
try
:
f
=
os
.
popen
(
cmd
)
f
=
os
.
popen
(
cmd
)
trace
=
f
.
read
()
try
:
f
.
close
()
trace
=
f
.
read
()
finally
:
f
.
close
()
finally
:
finally
:
try
:
try
:
os
.
unlink
(
ccout
)
os
.
unlink
(
ccout
)
...
@@ -70,7 +72,12 @@ elif os.name == "posix":
...
@@ -70,7 +72,12 @@ elif os.name == "posix":
if
not
f
:
if
not
f
:
return
None
return
None
cmd
=
"/usr/ccs/bin/dump -Lpv 2>/dev/null "
+
f
cmd
=
"/usr/ccs/bin/dump -Lpv 2>/dev/null "
+
f
res
=
re
.
search
(
r'\
[.*
\]\
sSONAME
\s+([^\
s]+)
', os.popen(cmd).read())
f
=
os
.
popen
(
cmd
)
try
:
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
r'\
[.*
\]\
sSONAME
\s+([^\
s]+)
', data)
if not res:
if not res:
return None
return None
return res.group(1)
return res.group(1)
...
@@ -80,7 +87,12 @@ elif os.name == "posix":
...
@@ -80,7 +87,12 @@ elif os.name == "posix":
if not f:
if not f:
return None
return None
cmd = "objdump -p -j .dynamic 2>/dev/null " + f
cmd = "objdump -p -j .dynamic 2>/dev/null " + f
res = re.search(r'
\
sSONAME
\
s
+
([
^
\
s
]
+
)
', os.popen(cmd).read())
f = os.popen(cmd)
try:
data = f.read()
finally:
f.close()
res = re.search(r'
\
sSONAME
\
s
+
([
^
\
s
]
+
)
', data)
if not res:
if not res:
return None
return None
return res.group(1)
return res.group(1)
...
@@ -103,8 +115,12 @@ elif os.name == "posix":
...
@@ -103,8 +115,12 @@ elif os.name == "posix":
def find_library(name):
def find_library(name):
ename = re.escape(name)
ename = re.escape(name)
expr = r'
:
-
l
%
s
\
.
\
S
+
=>
\
S
*/
(
lib
%
s
\
.
\
S
+
)
' % (ename, ename)
expr = r'
:
-
l
%
s
\
.
\
S
+
=>
\
S
*/
(
lib
%
s
\
.
\
S
+
)
' % (ename, ename)
res = re.findall(expr,
f = os.popen('
/
sbin
/
ldconfig
-
r
2
>/
dev
/
null
')
os.popen('
/
sbin
/
ldconfig
-
r
2
>/
dev
/
null
').read())
try:
data = f.read()
finally:
f.close()
res = re.findall(expr, data)
if not res:
if not res:
return _get_soname(_findLib_gcc(name))
return _get_soname(_findLib_gcc(name))
res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y)))
res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y)))
...
@@ -115,12 +131,21 @@ elif os.name == "posix":
...
@@ -115,12 +131,21 @@ elif os.name == "posix":
def _findLib_ldconfig(name):
def _findLib_ldconfig(name):
# XXX assuming GLIBC'
s
ldconfig
(
with
option
-
p
)
# XXX assuming GLIBC'
s
ldconfig
(
with
option
-
p
)
expr
=
r'/[^\
(
\)\
s]*li
b%s\
.[^
\(\
)
\s]*'
%
re
.
escape
(
name
)
expr
=
r'/[^\
(
\)\
s]*li
b%s\
.[^
\(\
)
\s]*'
%
re
.
escape
(
name
)
res
=
re
.
search
(
expr
,
f
=
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
)
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
).
read
())
try
:
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
expr
,
data
)
if
not
res
:
if
not
res
:
# Hm, this works only for libs needed by the python executable.
# Hm, this works only for libs needed by the python executable.
cmd
=
'ldd %s 2>/dev/null'
%
sys
.
executable
cmd
=
'ldd %s 2>/dev/null'
%
sys
.
executable
res
=
re
.
search
(
expr
,
os
.
popen
(
cmd
).
read
())
f
=
os
.
popen
(
cmd
)
try
:
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
expr
,
data
)
if
not
res
:
if
not
res
:
return
None
return
None
return
res
.
group
(
0
)
return
res
.
group
(
0
)
...
...
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