Avoid using a utility header for Python replacements included in Samba,
authorJelmer Vernooij <jelmer@samba.org>
Thu, 8 Jan 2009 11:20:20 +0000 (12:20 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 8 Jan 2009 11:20:20 +0000 (12:20 +0100)
since this will not be shipped with talloc/tdb/tevent/etc.

15 files changed:
lib/tdb/pytdb.c
lib/tevent/pytevent.c
lib/util/python_util.h [deleted file]
libcli/nbt/pynbt.c
pidl/lib/Parse/Pidl/Samba4/Python.pm
source4/auth/credentials/pycredentials.c
source4/lib/com/pycom.c
source4/lib/ldb/pyldb.c
source4/lib/messaging/pymessaging.c
source4/lib/registry/pyregistry.c
source4/librpc/ndr/py_security.c
source4/librpc/rpc/pyrpc.c
source4/param/pyparam.c
source4/scripting/python/pyglue.c
source4/web_server/wsgi.c

index f2e094423cee72271881a1a9f26d039b829f1d59..15a8d8a3e212c0995bf6acc194c4c7e875e23854 100644 (file)
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "../lib/util/python_util.h"
+#include <Python.h>
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 #ifdef HAVE_FSTAT
 #undef HAVE_FSTAT
 #endif
 #ifdef HAVE_FSTAT
 #undef HAVE_FSTAT
 #endif
index 756d013ede83b771aee82e6c5d2535ca1c2f0e0d..5d10554531ea3f9eba0d627fe1a9fb548c3ae258 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "../lib/util/python_util.h"
+#include <Python.h>
+
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 #include <tevent.h>
 #include <stdbool.h>
 #include <tevent_util.h>
 #include <tevent.h>
 #include <stdbool.h>
 #include <tevent_util.h>
diff --git a/lib/util/python_util.h b/lib/util/python_util.h
deleted file mode 100644 (file)
index 24033a4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Samba Python utility functions
-   Copyright (C) Tim Prouty <tprouty@samba.org> 2009
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PYTHON_UTIL_H_
-#define _PYTHON_UTIL_H_
-
-#include <Python.h>
-
-#if PY_VERSION_HEX < 0x02040000
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
-#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
-#endif
-
-#endif /* _PYTHON_UTIL_H_ */
index 99eff94bda3ade4bf8f331fca3df38608cafb83a..63ee9bb01ffd4eb5ef3bba7c22d2b2f8f1b5ece3 100644 (file)
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "libcli/util/pyerrors.h"
 #include "scripting/python/modules.h"
 #include "../libcli/nbt/libnbt.h"
 #include "lib/events/events.h"
 
 #include "libcli/util/pyerrors.h"
 #include "scripting/python/modules.h"
 #include "../libcli/nbt/libnbt.h"
 #include "lib/events/events.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 PyAPI_DATA(PyTypeObject) nbt_node_Type;
 
 typedef struct {
 PyAPI_DATA(PyTypeObject) nbt_node_Type;
 
 typedef struct {
index dd93605527b90e780d32f2a928a1196b5cfe7a36..6d25fcd24fc4b5793d054649baea4935f184b35e 100644 (file)
@@ -1121,13 +1121,17 @@ sub Parse($$$$$)
     $self->pidl_hdr("
 /* Python wrapper functions auto-generated by pidl */
 #include \"includes.h\"
     $self->pidl_hdr("
 /* Python wrapper functions auto-generated by pidl */
 #include \"includes.h\"
-#include \"../lib/util/python_util.h\"
+#include <Python.h>
 #include \"librpc/rpc/dcerpc.h\"
 #include \"lib/talloc/pytalloc.h\"
 #include \"librpc/rpc/pyrpc.h\"
 #include \"$hdr\"
 #include \"$ndr_hdr\"
 
 #include \"librpc/rpc/dcerpc.h\"
 #include \"lib/talloc/pytalloc.h\"
 #include \"librpc/rpc/pyrpc.h\"
 #include \"$hdr\"
 #include \"$ndr_hdr\"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 ");
 
        foreach my $x (@$ndr) {
 ");
 
        foreach my $x (@$ndr) {
index 6821170853f757e9e81c578c81483716d3ce5b7f..6fcab80ce66f6e37deb319508ebf4fc205349ece 100644 (file)
@@ -17,7 +17,7 @@
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "pycredentials.h"
 #include "param/param.h"
 #include "lib/cmdline/credentials.h"
 #include "pycredentials.h"
 #include "param/param.h"
 #include "lib/cmdline/credentials.h"
 #include "libcli/util/pyerrors.h"
 #include "param/pyparam.h"
 
 #include "libcli/util/pyerrors.h"
 #include "param/pyparam.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj)
 {
     if (py_obj == Py_None) {
 struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj)
 {
     if (py_obj == Py_None) {
index 753b7f8f9dabee4bd288eb3f6aa5f1659f38b641..d5a07580ea1dbf405b78372197368d474c585d61 100644 (file)
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "lib/com/com.h"
 #include "librpc/ndr/libndr.h"
 #include "libcli/util/pyerrors.h"
 
 #include "lib/com/com.h"
 #include "librpc/ndr/libndr.h"
 #include "libcli/util/pyerrors.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 static struct com_context *py_com_ctx = NULL; /* FIXME: evil global */
 
 static PyObject *py_get_class_object(PyObject *self, PyObject *args)
 static struct com_context *py_com_ctx = NULL; /* FIXME: evil global */
 
 static PyObject *py_get_class_object(PyObject *self, PyObject *args)
index b7a78e8f531607ff48a05e287d0af776eca865da..89ef7aeddf2e861fc2a5c9cd6234bcd34220817b 100644 (file)
@@ -26,7 +26,7 @@
 */
 
 #include "ldb_includes.h"
 */
 
 #include "ldb_includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "pyldb.h"
 
 /* There's no Py_ssize_t in 2.4, apparently */
 #include "pyldb.h"
 
 /* There's no Py_ssize_t in 2.4, apparently */
@@ -36,6 +36,10 @@ typedef inquiry lenfunc;
 typedef intargfunc ssizeargfunc;
 #endif
 
 typedef intargfunc ssizeargfunc;
 #endif
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 /* Picked out of thin air. To do this properly, we should probably have some part of the 
  * errors in LDB be allocated to bindings ? */
 #define LDB_ERR_PYTHON_EXCEPTION       142
 /* Picked out of thin air. To do this properly, we should probably have some part of the 
  * errors in LDB be allocated to bindings ? */
 #define LDB_ERR_PYTHON_EXCEPTION       142
index 3fa59bde573696defcff6cd800e1bb7d029e6ae3..535da4526c83230c9abd10dec733abdb1a953a98 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "scripting/python/modules.h"
 #include "libcli/util/pyerrors.h"
 #include "librpc/rpc/pyrpc.h"
 #include "scripting/python/modules.h"
 #include "libcli/util/pyerrors.h"
 #include "librpc/rpc/pyrpc.h"
 #include "cluster/cluster.h"
 #include "param/param.h"
 
 #include "cluster/cluster.h"
 #include "param/param.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 PyAPI_DATA(PyTypeObject) messaging_Type;
 PyAPI_DATA(PyTypeObject) irpc_ClientConnectionType;
 
 PyAPI_DATA(PyTypeObject) messaging_Type;
 PyAPI_DATA(PyTypeObject) irpc_ClientConnectionType;
 
index c28fcaa6851cddac0a132713120c064c02f32bb3..166543b6fddc373c50f9889f0a2623ffd5e55647 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "libcli/util/pyerrors.h"
 #include "lib/registry/registry.h"
 #include "scripting/python/modules.h" /* for py_iconv_convenience() */
 #include "libcli/util/pyerrors.h"
 #include "lib/registry/registry.h"
 #include "scripting/python/modules.h" /* for py_iconv_convenience() */
 #include <tevent.h>
 #include "param/pyparam.h"
 
 #include <tevent.h>
 #include "param/pyparam.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
 
 PyAPI_DATA(PyTypeObject) PyRegistryKey;
 extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
 
 PyAPI_DATA(PyTypeObject) PyRegistryKey;
index 5311ce18f4e0b2b5e43332ecbbed4df58b363bbb..08542640b99dbd861962f224943d3a862a180007 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "libcli/security/security.h"
 
 #include "libcli/security/security.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
 {
        PyObject *dict;
 static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
 {
        PyObject *dict;
index 1f29ad143ef729cd9675f329d5e78e6f86e16ad3..371e111c674766e894e954eeb120974d5520173d 100644 (file)
 */
 
 #include "includes.h"
 */
 
 #include "includes.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include <structmember.h>
 #include "librpc/rpc/pyrpc.h"
 #include "librpc/rpc/dcerpc.h"
 #include "lib/events/events.h"
 #include "param/pyparam.h"
 
 #include <structmember.h>
 #include "librpc/rpc/pyrpc.h"
 #include "librpc/rpc/dcerpc.h"
 #include "lib/events/events.h"
 #include "param/pyparam.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, struct PyNdrRpcMethodDef *md, PyObject *args, PyObject *kwargs)
 {
        TALLOC_CTX *mem_ctx;
 static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, struct PyNdrRpcMethodDef *md, PyObject *args, PyObject *kwargs)
 {
        TALLOC_CTX *mem_ctx;
index 1eef02ba39e301611fa86469a8ba9be026d0eea6..2d5a584fb2709656573de95464e83b022ecd959d 100644 (file)
@@ -23,7 +23,7 @@
 #include "includes.h"
 #include "param/param.h"
 #include "param/loadparm.h"
 #include "includes.h"
 #include "param/param.h"
 #include "param/loadparm.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "pytalloc.h"
 
 /* There's no Py_ssize_t in 2.4, apparently */
 #include "pytalloc.h"
 
 /* There's no Py_ssize_t in 2.4, apparently */
@@ -32,6 +32,10 @@ typedef int Py_ssize_t;
 typedef inquiry lenfunc;
 #endif
 
 typedef inquiry lenfunc;
 #endif
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 #define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_ptr(obj)
 
 PyAPI_DATA(PyTypeObject) PyLoadparmContext;
 #define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_ptr(obj)
 
 PyAPI_DATA(PyTypeObject) PyLoadparmContext;
index b11b5a5add5717d11895c9bb68b27b6078b4d672..a2c4790611e6c13027d03ba61bc5da9b70b61fcd 100644 (file)
 #include "lib/ldb-samba/ldif_handlers.h"
 #include "librpc/ndr/libndr.h"
 #include "version.h"
 #include "lib/ldb-samba/ldif_handlers.h"
 #include "librpc/ndr/libndr.h"
 #include "version.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
 #include "lib/ldb/pyldb.h"
 #include "libcli/util/pyerrors.h"
 #include "libcli/security/security.h"
 #include "auth/pyauth.h"
 #include "param/pyparam.h"
 
 #include "lib/ldb/pyldb.h"
 #include "libcli/util/pyerrors.h"
 #include "libcli/security/security.h"
 #include "auth/pyauth.h"
 #include "param/pyparam.h"
 
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
 /* FIXME: These should be in a header file somewhere, once we finish moving
  * away from SWIG .. */
 extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
 /* FIXME: These should be in a header file somewhere, once we finish moving
  * away from SWIG .. */
 extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
index 8ec30a476a514976a4ee37eaf8300ad999ad2482..53ba2a2d9b0c07769b1ec6eb2651cc8ea714e649 100644 (file)
 #include "../lib/util/dlinklist.h"
 #include "../lib/util/data_blob.h"
 #include "lib/tls/tls.h"
 #include "../lib/util/dlinklist.h"
 #include "../lib/util/data_blob.h"
 #include "lib/tls/tls.h"
-#include "../lib/util/python_util.h"
+#include <Python.h>
+
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
 
 typedef struct {
        PyObject_HEAD
 
 typedef struct {
        PyObject_HEAD