File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,5 +102,12 @@ def test_1703286_B(self):
102102 # This is the real test: call the function via 'call_function'
103103 self .assertEqual (0 , call_function (proc , (None ,)))
104104
105+ if os .name != "nt" :
106+ def test_libc_exists (self ):
107+ # A basic test that the libc is found by find_library()
108+ # XXX Can this fail on some non-Windows systems?
109+ self .assertTrue (libc_name )
110+ self .assertTrue (os .path .exists (libc_name ))
111+
105112if __name__ == "__main__" :
106113 unittest .main ()
Original file line number Diff line number Diff line change @@ -203,14 +203,18 @@ def _findSoname_ldconfig(name):
203203 abi_type = mach_map .get (machine , 'libc6' )
204204
205205 # XXX assuming GLIBC's ldconfig (with option -p)
206- expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]* lib%s\.[^\(\)\s]*)' \
207- % ( abi_type , re .escape (name ))
206+ name = ' lib%s' % name
207+ pat = re . compile ( '\s*(/[^\(\)\s]*%s\.[^\(\)\s]*)' % re .escape (name ))
208208 with contextlib .closing (os .popen ('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null' )) as f :
209- data = f .read ()
210- res = re .search (expr , data )
211- if not res :
212- return None
213- return res .group (1 )
209+ for line in f :
210+ if not '=>' in line :
211+ continue
212+ path = line .rsplit ('=>' , 1 )[1 ]
213+ if not name + '.' in path :
214+ continue
215+ res = pat .search (path )
216+ if res :
217+ return res .group (1 )
214218
215219 def find_library (name ):
216220 return _findSoname_ldconfig (name ) or _get_soname (_findLib_gcc (name ))
Original file line number Diff line number Diff line change @@ -329,6 +329,7 @@ Dag Gruneau
329329Michael Guravage
330330Lars Gustäbel
331331Thomas Güttler
332+ Jonas H.
332333Barry Haddow
333334Paul ten Hagen
334335Rasmus Hahn
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ Core and Builtins
3535Library
3636-------
3737
38+ - Issue #11258: Speed up ctypes.util.find_library() under Linux a lot. Patch
39+ by Jonas H.
40+
3841- Issue #11297: Add collections.ChainMap().
3942
4043- Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall.
You can’t perform that action at this time.
0 commit comments