From cb51beac60fc6d02b1ef1d2ee027ee90d84f5a95 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Nov 2002 20:58:45 +0000 Subject: Remove use of 'F' - make 'f' and 'p' do unix (iso8859-1) encoding. Jeremy. (This used to be commit e88bbec2a06bd92b8cfa33efdf166c4fa72cb656) --- source3/python/py_tdbpack.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 7a03f830ee..b79f96dbc6 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -235,13 +235,6 @@ pytdbpack_data(const char *format_str, case 'f': case 'P': - if (!(packed_list = pytdbpack_str(ch, val_iter, packed_list, pytdb_dos_encoding))) - return NULL; - break; - - case 'F': - /* We specify NULL encoding: Samba databases in this - form are written in the default Python encoding. */ if (!(packed_list = pytdbpack_str(ch, val_iter, packed_list, pytdb_unix_encoding))) return NULL; break; @@ -668,9 +661,6 @@ static PyObject *pytdbunpack_item(char ch, result = pytdbunpack_uint32(pbuf, plen); } else if (ch == 'f' || ch == 'P') { /* nul-term string */ - result = pytdbunpack_string(pbuf, plen, pytdb_dos_encoding); - } - else if (ch == 'F') { /* nul-term string */ result = pytdbunpack_string(pbuf, plen, pytdb_unix_encoding); } else if (ch == 'B') { /* length, buffer */ -- cgit From f069aaa6715e346c83cde78a04919fa8fdf01672 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Nov 2002 21:00:55 +0000 Subject: Fix comment - 850 -> iso8859-1 Jeremy. (This used to be commit 6639693746ba4c8f6622325ac143f8b1b3bd7538) --- source3/python/py_tdbpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index b79f96dbc6..d70937e8e0 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -69,7 +69,7 @@ to be the same as the default Python encoding). tdbpack format strings: - 'f': NUL-terminated string in codepage 850 + 'f': NUL-terminated string in codepage iso8859-1 'P': same as 'f' -- cgit From 9c7891e964500a8a5c516ad75f8664532323934b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 29 Nov 2002 02:44:09 +0000 Subject: Fixed silly bug. (This used to be commit 191c1596f5e939e733c9262c3beaf956328c7be6) --- source3/python/py_conv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/python') diff --git a/source3/python/py_conv.c b/source3/python/py_conv.c index 966a892528..e865daf7d9 100644 --- a/source3/python/py_conv.c +++ b/source3/python/py_conv.c @@ -45,7 +45,7 @@ PyObject *from_struct(void *s, struct pyconv *conv) fstring str = ""; if (u->buffer) - fstr_pull(s, u); + fstr_pull(str, u); item = PyString_FromString(str); PyDict_SetItemString(obj, conv[i].name, item); -- cgit From 73bf5369b8b9043f0e0d215f2aca42ae0bfe43a9 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 3 Dec 2002 21:49:00 +0000 Subject: use FILE_MACRO instead of __FILE__ use FUNCTION_MACRO instead of __FUNCTION_ (This used to be commit 243763d6eb107ab2444d81025232c8fe795baaf1) --- source3/python/py_tdbpack.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index d70937e8e0..8e294c7637 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -247,7 +247,7 @@ pytdbpack_data(const char *format_str, default: PyErr_Format(PyExc_ValueError, "%s: format character '%c' is not supported", - __FUNCTION__, ch); + FUNCTION_MACRO, ch); return NULL; } } @@ -477,7 +477,7 @@ pytdbunpack(PyObject *self, if (i == 0) { PyErr_Format(PyExc_ValueError, "%s: '$' may not be first character in format", - __FUNCTION__); + FUNCTION_MACRO); return NULL; } while (packed_len > 0) @@ -511,7 +511,7 @@ static void pytdbunpack_err_too_short(void) { PyErr_Format(PyExc_IndexError, - __FUNCTION__ ": data too short for unpack format"); + FUNCTION_MACRO ": data too short for unpack format"); } @@ -598,7 +598,7 @@ pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list) if (slen < 0) { /* surely you jest */ PyErr_Format(PyExc_ValueError, - __FUNCTION__ ": buffer seems to have negative length"); + FUNCTION_MACRO ": buffer seems to have negative length"); return NULL; } @@ -608,7 +608,7 @@ pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list) if (*plen < slen) { PyErr_Format(PyExc_IndexError, - __FUNCTION__ ": not enough data to unpack buffer: " + FUNCTION_MACRO ": not enough data to unpack buffer: " "need %d bytes, have %d", (int) slen, *plen); return NULL; @@ -668,7 +668,7 @@ static PyObject *pytdbunpack_item(char ch, } else { PyErr_Format(PyExc_ValueError, - __FUNCTION__ ": format character '%c' is not supported", + FUNCTION_MACRO ": format character '%c' is not supported", ch); return NULL; -- cgit From 8623ca6f82df2738f043bb4f344b050cd10281ed Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 4 Dec 2002 23:31:47 +0000 Subject: FUNCTION_MACRO change broke the Python modules. Also fix up string pasting (I thought this should only be a warning?) (This used to be commit 739285ff694e9ffd317ad47aec373e2007c20f45) --- source3/python/py_tdbpack.c | 23 ++++++++++++++++------- source3/python/setup.py | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 8e294c7637..6d23dd840a 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -23,9 +23,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "Python.h" +/* This module is supposed to be standalone, however for portability + it would be good to use the FUNCTION_MACRO preprocessor define. */ -#include "Python.h" +#include "config.h" + +#ifdef HAVE_FUNCTION_MACRO +#define FUNCTION_MACRO (__FUNCTION__) +#else +#define FUNCTION_MACRO (__FILE__) +#endif static PyObject * pytdbpack_number(char ch, PyObject *val_iter, PyObject *packed_list); static PyObject * pytdbpack_str(char ch, @@ -511,7 +520,7 @@ static void pytdbunpack_err_too_short(void) { PyErr_Format(PyExc_IndexError, - FUNCTION_MACRO ": data too short for unpack format"); + "%s: data too short for unpack format", FUNCTION_MACRO); } @@ -598,7 +607,7 @@ pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list) if (slen < 0) { /* surely you jest */ PyErr_Format(PyExc_ValueError, - FUNCTION_MACRO ": buffer seems to have negative length"); + "%s: buffer seems to have negative length", FUNCTION_MACRO); return NULL; } @@ -608,8 +617,8 @@ pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list) if (*plen < slen) { PyErr_Format(PyExc_IndexError, - FUNCTION_MACRO ": not enough data to unpack buffer: " - "need %d bytes, have %d", + "%s: not enough data to unpack buffer: " + "need %d bytes, have %d", FUNCTION_MACRO, (int) slen, *plen); return NULL; } @@ -668,8 +677,8 @@ static PyObject *pytdbunpack_item(char ch, } else { PyErr_Format(PyExc_ValueError, - FUNCTION_MACRO ": format character '%c' is not supported", - ch); + "%s: format character '%c' is not supported", + FUNCTION_MACRO, ch); return NULL; } diff --git a/source3/python/setup.py b/source3/python/setup.py index bf62f3b877..09a81fd914 100755 --- a/source3/python/setup.py +++ b/source3/python/setup.py @@ -179,6 +179,7 @@ setup( # tdbpack/unpack extensions. Does not actually link to any Samba # code, although it implements a compatible data format. Extension(name = "tdbpack", - sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")]), + sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")], + extra_compile_args = ["-I include"]) ], ) -- cgit From fad3464ffeea80281a8b4ae6f24f7c8a22433516 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 11 Dec 2002 01:25:18 +0000 Subject: Some more tweaking for compilation of py_tdbpack. (This used to be commit 89be695b2997e97dfc40afd17bb61b59b85634e4) --- source3/python/py_tdbpack.c | 2 +- source3/python/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 6d23dd840a..28cd529245 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -28,7 +28,7 @@ /* This module is supposed to be standalone, however for portability it would be good to use the FUNCTION_MACRO preprocessor define. */ -#include "config.h" +#include "include/config.h" #ifdef HAVE_FUNCTION_MACRO #define FUNCTION_MACRO (__FUNCTION__) diff --git a/source3/python/setup.py b/source3/python/setup.py index 09a81fd914..b15f906bc2 100755 --- a/source3/python/setup.py +++ b/source3/python/setup.py @@ -180,6 +180,6 @@ setup( # code, although it implements a compatible data format. Extension(name = "tdbpack", sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")], - extra_compile_args = ["-I include"]) + extra_compile_args = ["-I."]) ], ) -- cgit From 022a8537811115b20e21c3e7551d465fe606cb44 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Thu, 12 Dec 2002 04:44:47 +0000 Subject: * Ignore .pyc and .pyo files produced as a side-effect of running Python examples. (This used to be commit 3bb4bd3ed642a61e54c44c40c31f0e2242977614) --- source3/python/examples/tdbpack/.cvsignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 source3/python/examples/tdbpack/.cvsignore (limited to 'source3/python') diff --git a/source3/python/examples/tdbpack/.cvsignore b/source3/python/examples/tdbpack/.cvsignore new file mode 100644 index 0000000000..52e4e61140 --- /dev/null +++ b/source3/python/examples/tdbpack/.cvsignore @@ -0,0 +1,2 @@ +*.pyc +*.pyo -- cgit From aabcd65020396105c683ede6fd9b5bb01891b098 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Thu, 12 Dec 2002 05:24:55 +0000 Subject: CR1333: Fix memory leak when unpacking some structures. * (pytdbunpack_item): PyList_Append creates an additional reference to the appended object. Therefore, release the initial reference after it's added to the list. (This used to be commit 1e63dc101a5085a46b9632ba657e5d5cd7505751) --- source3/python/py_tdbpack.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source3/python') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 28cd529245..6181a4918e 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -656,21 +656,21 @@ pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list) Returns a reference to None, or NULL for failure. */ static PyObject *pytdbunpack_item(char ch, - char **pbuf, - int *plen, - PyObject *val_list) + char **pbuf, + int *plen, + PyObject *val_list) { - PyObject *result; + PyObject *unpacked; if (ch == 'w') { /* 16-bit int */ - result = pytdbunpack_int16(pbuf, plen); + unpacked = pytdbunpack_int16(pbuf, plen); } else if (ch == 'd' || ch == 'p') { /* 32-bit int */ /* pointers can just come through as integers */ - result = pytdbunpack_uint32(pbuf, plen); + unpacked = pytdbunpack_uint32(pbuf, plen); } else if (ch == 'f' || ch == 'P') { /* nul-term string */ - result = pytdbunpack_string(pbuf, plen, pytdb_unix_encoding); + unpacked = pytdbunpack_string(pbuf, plen, pytdb_unix_encoding); } else if (ch == 'B') { /* length, buffer */ return pytdbunpack_buffer(pbuf, plen, val_list); @@ -684,10 +684,15 @@ static PyObject *pytdbunpack_item(char ch, } /* otherwise OK */ - if (!result) - return NULL; - if (PyList_Append(val_list, result) == -1) + if (!unpacked) return NULL; + + if (PyList_Append(val_list, unpacked) == -1) + val_list = NULL; + + /* PyList_Append takes a new reference to the inserted object. + Therefore, we no longer need the original reference. */ + Py_DECREF(unpacked); return val_list; } -- cgit