1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

47 Commits

Author SHA1 Message Date
Andreas Schneider
9621a3d7a6 Use python.h from libreplace
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-20 15:37:33 +00:00
Douglas Bagnall
0eb459edd8 talloc: remove Python 2 #if clauses
Also fix an obsolete related comment.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Feb 17 14:52:26 UTC 2023 on atb-devel-224
2023-02-17 14:52:26 +00:00
Joseph Sutton
290c1dc097 python: Ensure reference counts are properly incremented
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19 01:32:34 +00:00
David Disseldorp
f5c8b1aa83 Bug 9931: change pytalloc source to LGPL
pytalloc is currently GPL, while the rest of talloc is LGPL.

This situation arose because pytalloc was originally developed under
source4/scripting/python/, and moved into talloc proper with commit
0f043c197c ("Move pytalloc to talloc
directory.", October 2008).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9931

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 16 18:17:43 UTC 2021 on sn-devel-184
2021-03-16 18:17:42 +00:00
Gary Lockyer
13a2f70a4d Fix clang 9 missing-field-initializer warnings
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-08 09:31:31 +00:00
Andrew Bartlett
75d87b29f1 py3: Remove PyStr_FromFormat() compatability macro
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard
function names.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24 17:24:27 +00:00
Noel Power
995e23f117 lib/talloc: squash 'cast between incompatible function types' warning
To avoid warning above produced by using
-Wcast-function-type we;

  + ensure PyCFunctions of type METH_NOARGS defined dummy arg

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-05-16 17:55:17 +00:00
Kristján Valur
0fa5a77f46 pytalloc: Check for errors during module initialization.
Signed-off-by: Kristján Valur <kristjan@rvx.is>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-26 03:03:23 +00:00
Timur I. Bakeyev
d3cbcbd5c0 Remove extra 0x prefix for the "%p" format specifiers, avoiding 0x0x0 strings in the output.
Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2018-05-16 18:06:23 +02:00
Stefan Metzmacher
2cae14df12 pytalloc: add pytalloc_GenericObject_{steal,reference}[_ex]()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-02-25 02:39:11 +01:00
Douglas Bagnall
2ba83ae49b pytalloc: avoid double 0x0x in repr strings
The %p format puts one in itself.

Before: <drsblobs.repsFromTo2 talloc based object at 0x0x1b551e0>
After:  <drsblobs.repsFromTo2 talloc based object at 0x1b551e0>

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-05-10 01:43:15 +02:00
Andrew Bartlett
80f2b36efb pytalloc: Add new BaseObject
This new object not only avoids the ABI issues of talloc.Object
it stores one more pointer, being the start of the array, and
so can be used to fix the PIDL bindings/talloc refcount issue.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-08 01:58:26 +01:00
Petr Viktorin
cd6615ecbd pytalloc: Port to Python 3
- Use native string for repr

- Use rich comparison
  Removes the deprecated tp_compare in favor of tp_richcompare.
  Disparate types cannot be compared (except for == and !=),
  and True or False objects are returned explicitly.

- Use Py_TYPE instead of ob_type
  This changed to conform to C aliasing rules,
  see http://legacy.python.org/dev/peps/pep-3123/

- Don't provide CObject creation function
  A PyCapsule based replacement would be possible,
  but might not be necessary considering the function is
  not used much.

- Use new-style module initialization

Build changes:

- Use ABI flag in the lib name and pkg-config template

- Use the SAMBA_CHECK_PYTHON macro for finding Python

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
2015-05-19 19:28:18 +02:00
Petr Viktorin
8ac9c860de pytalloc: Fix comparison of disparate types
When fed Python objects of different types, pytalloc_default_cmp
compared pointers to PyType objects that weren't part of an array,
resulting in undefined behavior.

This makes things a bit better (though it still casts ptrdiff_t to int).

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-04-24 01:50:11 +02:00
Björn Jacke
7abe51f840 talloc: remove unused variables
found by the IRIX compiler

Autobuild-User(master): Björn Jacke <bj@sernet.de>
Autobuild-Date(master): Thu Jul  5 23:50:54 CEST 2012 on sn-devel-104
2012-07-05 23:50:54 +02:00
Jelmer Vernooij
f8ec7f6cb1 pytalloc: Use consistent prefix for functions, add ABI file. 2011-08-10 15:36:21 +02:00
Jelmer Vernooij
fdb0aa2b04 Revert broken destructor changes. 2011-01-03 01:48:05 +01:00
Jelmer Vernooij
cbf504b0c5 s4-python: Properly call PyObject_Del from all destructors. 2011-01-03 01:48:04 +01:00
Jelmer Vernooij
5792fa90ac s4-python: Only set BASETYPE flag if subclassing is supported.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Jan  1 03:39:58 CET 2011 on sn-devel-104
2011-01-01 03:39:58 +01:00
Jelmer Vernooij
f5fe9c32ef s4-python: Add more prototypes. 2011-01-01 02:54:05 +01:00
Jelmer Vernooij
4350e0c3c9 s4-python: Properly call PyObject_Del from all destructors. 2011-01-01 02:54:05 +01:00
Jelmer Vernooij
8897935660 pytalloc: Add docstring for talloc.Object.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sun Dec  5 18:12:59 CET 2010 on sn-devel-104
2010-12-05 18:12:59 +01:00
Jelmer Vernooij
efd8fc0672 pytalloc: Make py_talloc_default_cmp private. 2010-12-01 01:48:25 +01:00
Jelmer Vernooij
b8dc3c8a83 pytalloc: Make py_talloc_dealloc private. 2010-12-01 01:48:25 +01:00
Jelmer Vernooij
4f0436f107 pytalloc: Make py_talloc_default_repr private (now exposed by talloc.Object). 2010-12-01 01:48:25 +01:00
Jelmer Vernooij
e8aa266c97 talloc: Add talloc object.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Tue Nov 30 23:26:56 CET 2010 on sn-devel-104
2010-11-30 23:26:56 +01:00
Jelmer Vernooij
0d6f1a1630 pytalloc: Make some arguments optional. 2010-11-07 01:39:39 +01:00
Jelmer Vernooij
cd172e7724 talloc: Add python talloc module, move convenience functions to it.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Fri Nov  5 02:48:21 UTC 2010 on sn-devel-104
2010-11-05 02:48:21 +00:00
Jelmer Vernooij
4edabb3256 talloc: rename pytalloc.c to pytalloc_util.c 2010-11-05 02:06:06 +00:00
Stefan Metzmacher
177aad556f talloc: pytalloc should not depend on samba specific code
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Sun Oct 24 19:21:25 UTC 2010 on sn-devel-104
2010-10-24 19:21:25 +00:00
Kamen Mazdrashki
c0b9526aaf pytalloc: use talloc_unlink() to free py_talloc objects
Those type of objects are referenced every time we assign
them to other py_talloc objects, which leads to runtime
warnings that we are trying to free an object with references

Wrap talloc_unlink() in SMB_ASSERT() to ensure we catch possible failure

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Wed Oct 20 21:37:06 UTC 2010 on sn-devel-104
2010-10-20 21:37:06 +00:00
Kamen Mazdrashki
76a8ae9e0d pytalloc: Fix warning that we are subtracting void* pointers
Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Fri Oct  8 23:36:54 UTC 2010 on sn-devel-104
2010-10-08 23:36:54 +00:00
Jelmer Vernooij
049c4fa04d pytalloc: Add default compare function. 2010-09-21 11:47:03 -07:00
Jelmer Vernooij
a7393449eb pidl: Fix segfault when accessing unicode objects. 2010-09-20 22:40:46 -07:00
Andrew Tridgell
58d92cefe2 pidl-python: cope with NULL pointers in more places
NULL is converted to Py_None
2010-09-02 13:37:07 +10:00
Andrew Tridgell
e7e39584a9 pytalloc: treat a NULL ptr as Py_None 2010-09-02 13:37:07 +10:00
Andrew Tridgell
634e06e465 pytalloc: fixed py_talloc_steal()
py_talloc_steal() was implemented as a macro which evaluated it's 2nd
argument twice. It was often called via a macro with a 2nd argument
that was a function call, for example an allocation in
py_talloc_new(). This meant it allocated memory twice, and leaked one
of them.

This re-implements py_talloc_steal() as a function, so that it only
does the allocation once.
2010-08-25 23:05:05 +10:00
Andrew Tridgell
d78417a5d6 s4-pytalloc: use better names for python talloc objects 2010-08-25 23:05:05 +10:00
Andrew Tridgell
7ed349cace pytalloc: allow for using a system libtalloc-dev with pytalloc
When we have a system talloc library, we still need to grab pytalloc.h
from lib/talloc. We don't want to just use -Ilib/talloc, as otherwise
we'll get the in-tree talloc.h which may not be compatible with the
system talloc.h

So we need to give the path to pytalloc.h
2010-03-29 21:34:29 +11:00
Jelmer Vernooij
c42242d132 s4: Include Python.h early to avoid double definition errors. 2010-01-21 16:15:10 +13:00
Jelmer Vernooij
830adcd58d pidl: Avoid using talloc_free as function pointer, since it may be a
macro.
2009-09-28 15:03:17 +02:00
Jelmer Vernooij
6768cfe624 DCE/RPC(Python): Rename py_talloc_import to py_talloc_steal.
Use py_talloc_reference in DCE/RPC code, fixes
					access to SAMR pipe.
2009-07-30 20:04:42 +02:00
Andrew Tridgell
956b5a0003 fixed use of reference in pytalloc
The previous code caused memory leaks, and also caused situations
where talloc_free could be called on pointers with multiple parents

The new approach is to have two functions:

  py_talloc_import : steals the pointer, so it becomes wholly owned by
                     the python object
  py_talloc_reference: uses a reference, so it is owned by both python
                     and C
2009-07-01 15:15:37 +10:00
Stefan Metzmacher
2f8a398296 lib/talloc: include replace.h in pytalloc.c
This fixes the build on Tru64.

metze
2009-01-30 19:38:09 +01:00
Jelmer Vernooij
86cee0b28c pytalloc: Add some comments, use talloc object location in repr rather
than python object location.
2008-12-23 04:06:21 +01:00
Jelmer Vernooij
2e7a6cb6bf py: Fix initialisation of subtypes, fix segfaults. 2008-12-21 03:08:14 +01:00
Jelmer Vernooij
0f043c197c Move pytalloc to talloc directory. 2008-10-24 02:52:51 +02:00