[GRASS-SVN] r73339 - grass/trunk/lib/python/ctypes

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 15 20:16:58 PDT 2018


Author: annakrat
Date: 2018-09-15 20:16:58 -0700 (Sat, 15 Sep 2018)
New Revision: 73339

Modified:
   grass/trunk/lib/python/ctypes/preamble.py
Log:
ctypes: put back function removed during porting to Python 3, it is needed otherwise errors like the one in #3641 appears

Modified: grass/trunk/lib/python/ctypes/preamble.py
===================================================================
--- grass/trunk/lib/python/ctypes/preamble.py	2018-09-16 02:45:09 UTC (rev 73338)
+++ grass/trunk/lib/python/ctypes/preamble.py	2018-09-16 03:16:58 UTC (rev 73339)
@@ -22,6 +22,22 @@
 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):



More information about the grass-commit mailing list