reassign 509125 python
retitle 509125 ctypes.utils.find_library() fails to find some libraries
with non-English locales
tags 509125 + patch
thanks
Well, that was a tricky (and funny) bug. After investigating, it appears
the problem does not come from Impressive! or from PyOpenGL but from
Python's ctypes.utils.find_library() itself.
Here is the symptom; as you will see it is locale-related:
% LANG=fr_FR.UTF-8 python
>>> from util import find_library
>>> find_library("GLU")
'libGLU.so.1'
>>> find_library("GL")
[nothing]
While:
% LANG=C python
>>> from ctypes.util import find_library
>>> find_library("GLEW")
'libGLEW.so.1.6'
>>> find_library("GL")
'libGL.so.1'
Tracking down this issue, I could determine that it came from
the fact that find_library() was using ldconfig -p's output, which was
localized. Specifically:
% LANG=fr_FR.UTF-8 ldconfig -p | grep -F libGL.
libGL.so.1 (libc6,x86-64, Système d'exploitation ABI : Linux 2.4.20) =>
/usr/lib/x86_64-linux-gnu/libGL.so.1
libGL.so.1 (libc6, Système d'exploitation ABI : Linux 2.4.20) =>
/usr/lib32/libGL.so.1
While:
% LANG=C ldconfig -p | grep -F libGL.
libGL.so.1 (libc6,x86-64, OS ABI: Linux 2.4.20) =>
/usr/lib/x86_64-linux-gnu/libGL.so.1
libGL.so.1 (libc6, OS ABI: Linux 2.4.20) => /usr/lib32/libGL.so.1
find_library() applies a regex to this filter, which expects the English
result (ctypes/utils.py:234):
expr = r'(\S+)\s+\((%s(?:, OS
ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \
% (abi_type, re.escape(name))
So, here is a very patch to make that work regardless of the locale,
changing the ldconfig call in ctypes/utils.py:236 so that is forces the
C locale:
f = os.popen('LC_ALL=C /sbin/ldconfig -p 2>/dev/null')
Regards,
--
,--.
: /` ) Tanguy Ortolo <xmpp:[email protected]> <irc://irc.oftc.net/Tanguy>
| `-' Debian Developer
\_
--- /tmp/util.py 2012-02-24 10:08:04.760265372 +0100
+++ util.py 2012-02-24 10:09:57.888557986 +0100
@@ -233,7 +233,7 @@
# XXX assuming GLIBC's ldconfig (with option -p)
expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \
% (abi_type, re.escape(name))
- f = os.popen('/sbin/ldconfig -p 2>/dev/null')
+ f = os.popen('LC_ALL=C /sbin/ldconfig -p 2>/dev/null')
try:
data = f.read()
finally:
signature.asc
Description: Digital signature
_______________________________________________ Python-modules-team mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

