Commits

jiangwen365 committed 1c3395d Merge

Merged in clach04/pypyodbc (pull request #3: CPython 2.5 support.)

  • Participants
  • Parent commits 18a7105, e7692bd

Comments (0)

Files changed (1)

File pypyodbc/pypyodbc.py

 # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 # DEALINGS IN THE SOFTWARE.
 
-
+from __future__ import with_statement
 
 import sys, os, datetime, ctypes, threading
 from decimal import Decimal
 
+try:
+    bytearray
+except NameError:
+    # pre 2.6
+    bytearray = str
+
+if not hasattr(ctypes, 'c_ssize_t'):
+    if ctypes.sizeof(ctypes.c_uint) == ctypes.sizeof(ctypes.c_void_p):
+        ctypes.c_ssize_t = ctypes.c_int
+    elif ctypes.sizeof(ctypes.c_ulong) == ctypes.sizeof(ctypes.c_void_p):
+        ctypes.c_ssize_t = ctypes.c_long
+    elif ctypes.sizeof(ctypes.c_ulonglong) == ctypes.sizeof(ctypes.c_void_p):
+        ctypes.c_ssize_t = ctypes.c_longlong
+
 DEBUG = 0
 # Comment out all "if DEBUG:" statements like below for production
 if DEBUG: print 'DEBUGGING'
 
 def to_wchar(argtypes):
     if argtypes: # Under IronPython some argtypes are not declared
-        return [
-            wchar_type if x == ctypes.c_char_p else x
-            for x in argtypes
-        ]
+        result = []
+        for x in argtypes:
+            if x == ctypes.c_char_p:
+                result.append(wchar_type)
+            else:
+                result.append(x)
+        return result
     else:
         return argtypes