[pypy-svn] r50687 - pypy/dist/pypy/lib/_ctypes

fijal at codespeak.net fijal at codespeak.net
Wed Jan 16 21:04:01 CET 2008


Author: fijal
Date: Wed Jan 16 21:04:01 2008
New Revision: 50687

Modified:
   pypy/dist/pypy/lib/_ctypes/basics.py
Log:
Make address accepted, even if it's negative


Modified: pypy/dist/pypy/lib/_ctypes/basics.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/basics.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/basics.py	Wed Jan 16 21:04:01 2008
@@ -1,5 +1,6 @@
 
 import _rawffi
+import sys
 
 class _CDataMeta(type):
     def from_param(self, value):
@@ -80,6 +81,8 @@
     return pointer(cdata)
 
 def cdata_from_address(self, address):
+    # fix the address, in case it's unsigned
+    address = address & (sys.maxint * 2 + 1)
     instance = self.__new__(self)
     lgt = getattr(self, '_length_', 1)
     instance._buffer = self._ffiarray.fromaddress(address, lgt)



More information about the Pypy-commit mailing list