[pypy-svn] r69645 - pypy/trunk/pypy/rpython/lltypesystem
fijal at codespeak.net
fijal at codespeak.net
Thu Nov 26 01:17:12 CET 2009
Author: fijal
Date: Thu Nov 26 01:17:11 2009
New Revision: 69645
Modified:
pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
* User version_info instead of version, bah
* Happy ctypes mess. LoadLibrary does not accept kwargs of CDLL, hack hack hack
Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py Thu Nov 26 01:17:11 2009
@@ -6,7 +6,7 @@
except ImportError:
ctypes = None
-if sys.version >= (2, 6):
+if sys.version_info >= (2, 6):
load_library_kwargs = {'use_errno': True}
else:
load_library_kwargs = {}
@@ -813,8 +813,8 @@
return ctypes.util.find_library('c')
libc_name = get_libc_name() # Make sure the name is determined during import, not at runtime
- standard_c_lib = ctypes.cdll.LoadLibrary(get_libc_name(),
- **load_library_kwargs)
+ # XXX is this always correct???
+ standard_c_lib = ctypes.CDLL(get_libc_name(), **load_library_kwargs)
# ____________________________________________
@@ -903,7 +903,7 @@
# on ie slackware there was need for RTLD_GLOBAL here.
# this breaks a lot of things, since passing RTLD_GLOBAL
# creates symbol conflicts on C level.
- clib = dllclass.LoadLibrary(libpath, **load_library_kwargs)
+ clib = dllclass._dlltype(libpath, **load_library_kwargs)
cfunc = get_on_lib(clib, funcname)
if cfunc is not None:
break
@@ -1215,7 +1215,7 @@
# on 2.6 ctypes does it right, use it
-if sys.version >= (2, 6):
+if sys.version_info >= (2, 6):
def _save_c_errno():
TLS.errno = ctypes.get_errno()
@@ -1235,18 +1235,18 @@
if hasattr(TLS, 'errno'):
_where_is_errno().contents.value = TLS.errno
-if ctypes:
- if sys.platform == 'win32':
- standard_c_lib._errno.restype = ctypes.POINTER(ctypes.c_int)
- def _where_is_errno():
- return standard_c_lib._errno()
-
- elif sys.platform in ('linux2', 'freebsd6'):
- standard_c_lib.__errno_location.restype = ctypes.POINTER(ctypes.c_int)
- def _where_is_errno():
- return standard_c_lib.__errno_location()
-
- elif sys.platform in ('darwin', 'freebsd7'):
- standard_c_lib.__error.restype = ctypes.POINTER(ctypes.c_int)
- def _where_is_errno():
- return standard_c_lib.__error()
+ if ctypes:
+ if sys.platform == 'win32':
+ standard_c_lib._errno.restype = ctypes.POINTER(ctypes.c_int)
+ def _where_is_errno():
+ return standard_c_lib._errno()
+
+ elif sys.platform in ('linux2', 'freebsd6'):
+ standard_c_lib.__errno_location.restype = ctypes.POINTER(ctypes.c_int)
+ def _where_is_errno():
+ return standard_c_lib.__errno_location()
+
+ elif sys.platform in ('darwin', 'freebsd7'):
+ standard_c_lib.__error.restype = ctypes.POINTER(ctypes.c_int)
+ def _where_is_errno():
+ return standard_c_lib.__error()
More information about the Pypy-commit
mailing list