clach04 avatar clach04 committed e7692bd

CPython 2.5 support.

Comments (0)

Files changed (1)

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
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.