Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5ccfa29f
Kaydet (Commit)
5ccfa29f
authored
Eki 23, 2009
tarafından
Eric Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changed try/finally to contextlib.closing, as discussed in issue 6882.
üst
09d95625
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
24 deletions
+7
-24
util.py
Lib/ctypes/util.py
+7
-24
No files found.
Lib/ctypes/util.py
Dosyayı görüntüle @
5ccfa29f
import
sys
,
os
import
sys
,
os
import
contextlib
# find_library(name) returns the pathname of a library, or None.
# find_library(name) returns the pathname of a library, or None.
if
os
.
name
==
"nt"
:
if
os
.
name
==
"nt"
:
...
@@ -117,11 +118,8 @@ elif os.name == "posix":
...
@@ -117,11 +118,8 @@ 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
f
=
os
.
popen
(
cmd
)
with
contextlib
.
closing
(
os
.
popen
(
cmd
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
r'\[.*\]\sSONAME\s+([^\s]+)'
,
data
)
res
=
re
.
search
(
r'\[.*\]\sSONAME\s+([^\s]+)'
,
data
)
if
not
res
:
if
not
res
:
return
None
return
None
...
@@ -138,11 +136,8 @@ elif os.name == "posix":
...
@@ -138,11 +136,8 @@ elif os.name == "posix":
rv
=
f
.
close
()
rv
=
f
.
close
()
if
rv
==
10
:
if
rv
==
10
:
raise
OSError
(
'objdump command not found'
)
raise
OSError
(
'objdump command not found'
)
f
=
os
.
popen
(
cmd
)
with
contextlib
.
closing
(
os
.
popen
(
cmd
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
r'\sSONAME\s+([^\s]+)'
,
data
)
res
=
re
.
search
(
r'\sSONAME\s+([^\s]+)'
,
data
)
if
not
res
:
if
not
res
:
return
None
return
None
...
@@ -166,11 +161,8 @@ elif os.name == "posix":
...
@@ -166,11 +161,8 @@ 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
)
f
=
os
.
popen
(
'/sbin/ldconfig -r 2>/dev/null'
)
with
contextlib
.
closing
(
os
.
popen
(
'/sbin/ldconfig -r 2>/dev/null'
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
findall
(
expr
,
data
)
res
=
re
.
findall
(
expr
,
data
)
if
not
res
:
if
not
res
:
return
_get_soname
(
_findLib_gcc
(
name
))
return
_get_soname
(
_findLib_gcc
(
name
))
...
@@ -182,20 +174,14 @@ elif os.name == "posix":
...
@@ -182,20 +174,14 @@ 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]*lib
%
s\.[^\(\)\s]*'
%
re
.
escape
(
name
)
expr
=
r'/[^\(\)\s]*lib
%
s\.[^\(\)\s]*'
%
re
.
escape
(
name
)
f
=
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
)
with
contextlib
.
closing
(
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
expr
,
data
)
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
f
=
os
.
popen
(
cmd
)
with
contextlib
.
closing
(
os
.
popen
(
cmd
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
expr
,
data
)
res
=
re
.
search
(
expr
,
data
)
if
not
res
:
if
not
res
:
return
None
return
None
...
@@ -219,11 +205,8 @@ elif os.name == "posix":
...
@@ -219,11 +205,8 @@ elif os.name == "posix":
# XXX assuming GLIBC's ldconfig (with option -p)
# XXX assuming GLIBC's ldconfig (with option -p)
expr
=
r'(\S+)\s+\((
%
s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib
%
s\.[^\(\)\s]*)'
\
expr
=
r'(\S+)\s+\((
%
s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib
%
s\.[^\(\)\s]*)'
\
%
(
abi_type
,
re
.
escape
(
name
))
%
(
abi_type
,
re
.
escape
(
name
))
f
=
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
)
with
contextlib
.
closing
(
os
.
popen
(
'/sbin/ldconfig -p 2>/dev/null'
))
as
f
:
try
:
data
=
f
.
read
()
data
=
f
.
read
()
finally
:
f
.
close
()
res
=
re
.
search
(
expr
,
data
)
res
=
re
.
search
(
expr
,
data
)
if
not
res
:
if
not
res
:
return
None
return
None
...
...
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