Bläddra i källkod

ctypes: put back function removed during porting to Python 3, it is needed otherwise errors like the one in https://trac.osgeo.org/grass/ticket/3641 appears

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73339 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 år sedan
förälder
incheckning
0eb7d90d4d
1 ändrade filer med 16 tillägg och 0 borttagningar
  1. 16 0
      lib/python/ctypes/preamble.py

+ 16 - 0
lib/python/ctypes/preamble.py

@@ -22,6 +22,22 @@ del t
 del _int_types
 
 
+def POINTER(obj):
+    p = ctypes.POINTER(obj)
+
+    # Convert None to a real NULL pointer to work around bugs
+    # in how ctypes handles None on 64-bit platforms
+    if not isinstance(p.from_param, classmethod):
+        def from_param(cls, x):
+            if x is None:
+                return cls()
+            else:
+                return x
+        p.from_param = classmethod(from_param)
+
+    return p
+
+
 class UserString:
     def __init__(self, seq):
         if isinstance(seq, basestring):