summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-03-17 07:50:22 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-03-17 07:50:22 (GMT)
commit32f2eb4941db115d4d5d0902ba086820406ef4b2 (patch)
treebd021d3cd79192943a8a4fdb0820205eee80f2f8
parentec195fba5b4381b8b60fe8f9b400437f52b98371 (diff)
downloadcpython-32f2eb4941db115d4d5d0902ba086820406ef4b2.zip
cpython-32f2eb4941db115d4d5d0902ba086820406ef4b2.tar.gz
cpython-32f2eb4941db115d4d5d0902ba086820406ef4b2.tar.bz2
Issue #21042: Revert Linux find_library() to return just filename
This reverts most of revision 3092cf163eb4. The change worked on x86 architectures, but did not work on ARM, probably due to extra ABI flags in the ldconfig output.
-rw-r--r--Doc/library/ctypes.rst11
-rw-r--r--Lib/ctypes/test/test_find.py40
-rw-r--r--Lib/ctypes/util.py2
-rw-r--r--Misc/NEWS3
4 files changed, 21 insertions, 35 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 4a7309e..828d7ca4 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1258,15 +1258,15 @@ The exact functionality is system dependent.
On Linux, :func:`find_library` tries to run external programs
(``/sbin/ldconfig``, ``gcc``, and ``objdump``) to find the library file. It
-returns the absolute path of the library file. Here are some examples::
+returns the filename of the library file. Here are some examples::
>>> from ctypes.util import find_library
>>> find_library("m")
- '/lib/x86_64-linux-gnu/libm.so.6'
+ 'libm.so.6'
>>> find_library("c")
- '/lib/x86_64-linux-gnu/libc.so.6'
+ 'libc.so.6'
>>> find_library("bz2")
- '/lib/x86_64-linux-gnu/libbz2.so.1.0'
+ 'libbz2.so.1.0'
>>>
On OS X, :func:`find_library` tries several predefined naming schemes and paths
@@ -1835,9 +1835,6 @@ Utility functions
The exact functionality is system dependent.
- .. versionchanged:: 3.6
- On Linux it returns an absolute path.
-
.. function:: find_msvcrt()
:module: ctypes.util
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index 1845bb0..e6bc19d 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -9,39 +9,39 @@ from ctypes.util import find_library
class Test_OpenGL_libs(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.lib_gl = cls.lib_glu = cls.lib_gle = None
+ lib_gl = lib_glu = lib_gle = None
if sys.platform == "win32":
- cls.lib_gl = find_library("OpenGL32")
- cls.lib_glu = find_library("Glu32")
+ lib_gl = find_library("OpenGL32")
+ lib_glu = find_library("Glu32")
elif sys.platform == "darwin":
- cls.lib_gl = cls.lib_glu = find_library("OpenGL")
+ lib_gl = lib_glu = find_library("OpenGL")
else:
- cls.lib_gl = find_library("GL")
- cls.lib_glu = find_library("GLU")
- cls.lib_gle = find_library("gle")
+ lib_gl = find_library("GL")
+ lib_glu = find_library("GLU")
+ lib_gle = find_library("gle")
## print, for debugging
if test.support.verbose:
print("OpenGL libraries:")
- for item in (("GL", cls.lib_gl),
- ("GLU", cls.lib_glu),
- ("gle", cls.lib_gle)):
+ for item in (("GL", lib_gl),
+ ("GLU", lib_glu),
+ ("gle", lib_gle)):
print("\t", item)
cls.gl = cls.glu = cls.gle = None
- if cls.lib_gl:
+ if lib_gl:
try:
- cls.gl = CDLL(cls.lib_gl, mode=RTLD_GLOBAL)
+ cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
except OSError:
pass
- if cls.lib_glu:
+ if lib_glu:
try:
- cls.glu = CDLL(cls.lib_glu, RTLD_GLOBAL)
+ cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
except OSError:
pass
- if cls.lib_gle:
+ if lib_gle:
try:
- cls.gle = CDLL(cls.lib_gle)
+ cls.gle = CDLL(lib_gle)
except OSError:
pass
@@ -64,14 +64,6 @@ class Test_OpenGL_libs(unittest.TestCase):
self.skipTest('lib_gle not available')
self.gle.gleGetJoinStyle
- def test_abspath(self):
- if self.lib_gl:
- self.assertTrue(os.path.isabs(self.lib_gl))
- if self.lib_glu:
- self.assertTrue(os.path.isabs(self.lib_glu))
- if self.lib_gle:
- self.assertTrue(os.path.isabs(self.lib_gle))
-
# On platforms where the default shared library suffix is '.so',
# at least some libraries can be loaded as attributes of the cdll
# object, since ctypes now tries loading the lib again
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index d8e3bfa..38bd57f 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -221,7 +221,7 @@ elif os.name == "posix":
abi_type = mach_map.get(machine, 'libc6')
# XXX assuming GLIBC's ldconfig (with option -p)
- regex = r'lib%s\.[^\s]+\s\(%s(?:,\s.*)?\)\s=>\s(.*)'
+ regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
regex = os.fsencode(regex % (re.escape(name), abi_type))
try:
with subprocess.Popen(['/sbin/ldconfig', '-p'],
diff --git a/Misc/NEWS b/Misc/NEWS
index 8338a84..7f93b2b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -245,9 +245,6 @@ Library
- Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
-- Issue #21042: Make ctypes.util.find_library() return the full path on
- Linux, similar to other platforms. Patch by Tamás Bence Gedai.
-
- Issue #15068: Got rid of excessive buffering in fileinput.
The bufsize parameter is now deprecated and ignored.