From 2fbd93027d735413348cde1f9fe9d25a4f34e5d2 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 26 Jun 2015 17:45:28 -0500
Subject: [PATCH] Doc and callback fixes

---
 doc/conf.py       |  2 +-
 doc/reference.rst |  8 --------
 gen_wrap.py       | 14 +++++++-------
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/doc/conf.py b/doc/conf.py
index e3c4c57..4f5281e 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -41,7 +41,7 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'islpy'
-copyright = u'2011, Andreas Kloeckner'
+copyright = u'2011-15, Andreas Kloeckner'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
diff --git a/doc/reference.rst b/doc/reference.rst
index 1a5261e..0354557 100644
--- a/doc/reference.rst
+++ b/doc/reference.rst
@@ -85,10 +85,6 @@ Error Reporting
 Symbolic Constants
 ^^^^^^^^^^^^^^^^^^
 
-.. autoclass:: format
-    :members:
-    :undoc-members:
-
 .. autoclass:: error
     :members:
     :undoc-members:
@@ -104,10 +100,6 @@ Symbolic Constants
     :undoc-members:
     :exclude-members: names, values
 
-.. autoclass:: constants
-    :members:
-    :undoc-members:
-
 .. autoclass:: ast_op_type
     :members:
     :undoc-members:
diff --git a/gen_wrap.py b/gen_wrap.py
index c4e0fb9..16f4717 100644
--- a/gen_wrap.py
+++ b/gen_wrap.py
@@ -294,8 +294,6 @@ typedef isl_restriction *(*isl_access_restrict)(
 """
 
 PY_PREAMBLE = """
-from __future__ import print_function
-
 import six
 
 
@@ -927,9 +925,9 @@ def gen_callback_wrapper(gen, cb, func_name, has_userptr):
                         py_cls=isl_class_to_py_class(arg.base_type)))
 
             if arg.semantics is SEM_TAKE:
-                pass
-            elif arg.semantics is SEM_KEEP:
                 post_call("_py_{name}._release()".format(name=arg.name))
+            elif arg.semantics is SEM_KEEP:
+                pass
             else:
                 raise SignatureNotSupported(
                         "callback arg semantics not understood: %s" % arg.semantics)
@@ -953,7 +951,7 @@ def gen_callback_wrapper(gen, cb, func_name, has_userptr):
         failure_return = "ffi.NULL"
 
         ret_py_cls = isl_class_to_py_class(cb.return_base_type)
-        pre_call("""
+        post_call("""
             if not isinstance(_result, {py_cls}):
                 raise IslTypeError("return value is not a {py_cls}")
             """
@@ -994,8 +992,10 @@ def gen_callback_wrapper(gen, cb, func_name, has_userptr):
         gen("""
             except Exception as e:
                 import sys
-                print("[WARNING] An exception occurred in a callback function."
-                    "This exception was ignored.", file=sys.stderr)
+                sys.stderr.write("[WARNING] An exception occurred "
+                    "in a callback function."
+                    "This exception was ignored.\\n")
+                sys.stderr.flush()
                 import traceback
                 traceback.print_exc()
 
-- 
GitLab