1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/lib/ldb
Noel Power 7b170206b4 lib/ldb: Implement a bytes derived object for attributes py2/py3
ldb attributes are either bytes (py3) or str (py2)

Some places in the code do str(res[0]['attribute'][0])
which results in
   'result' (py2)
  b'result' (py3)

or more commonly the attribute is used to construct a string e.g.
   "blah=" + res[0]['attribute'][0] + ",foo,bar=...."

giving
   "blah=result,foo,bar=...." (py2)
and very unhelpfully
   "blah=b'result',foo,bar=...." (py3)

lots of code already constructs various strings for passing to other
api using the above. To avoid many excessive
    res[0]['attribute'][0].decode('utf8')

code like 'res[0]['attribute'][0]'

will now return LdbBytes (a new object subclassing 'bytes') in py3
instead of bytes. This object has a custom '__str__' method which
attempts to return a string decoded to uft8. In Py2 this will behave as
it did previously (this is the safer option at the moment)

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-07-13 01:12:24 +02:00
..
ABI ldb: version 1.4.1 2018-07-12 07:43:22 +02:00
common ldb: Reset error string before running prepare_commit() hook 2018-05-30 04:23:26 +02:00
docs
examples
include ldb: Ban ldb 1.4.x with Samba 4.8 and earlier 2018-07-12 04:32:08 +02:00
ldb_ldap ldb: allow a timeout of -1 result in no timeout timer at all. 2016-02-17 03:43:22 +01:00
ldb_ldb ldb: Add MDB support to ldb:// 2018-05-23 02:27:12 +02:00
ldb_map lib:ldb: Add FALL_THROUGH statements in ldb_map/ldb_map_outbound.c 2018-03-01 04:37:41 +01:00
ldb_mdb ldb_mdb: Remove implicit read lock and remove transaction counter 2018-05-23 02:27:11 +02:00
ldb_sqlite3 ldb: relatively efficient functions for finding duplicate values 2017-06-15 17:33:10 +02:00
ldb_tdb check return value before using key_values 2018-06-23 02:00:28 +02:00
man man pages: change http://samba.org to https://www.samba.org 2016-12-09 13:10:26 +01:00
modules lib: Hold at most 10 outstanding paged result cookies 2018-05-15 09:37:21 +02:00
nssldb
tests ldb: Add tests for when we should expect a full scan 2018-05-30 04:23:28 +02:00
tools ldb_mdb: Implement the lmdb backend for ldb 2018-05-23 02:27:10 +02:00
web
_ldb_text.py pyldb: Split text/byte strings for compatibility with Python 3 2015-11-05 18:04:24 +01:00
configure
Doxyfile
examples.dox
ldb.pc.in
mainpage.dox
Makefile
pyldb_util.c lib/ldb: Additionally accept unicode as string param in Py2 2018-04-30 15:43:19 +02:00
pyldb-util.pc.in lib/ldb: Enable use of a python3 pyldb-util system library 2017-03-10 07:31:10 +01:00
pyldb.c lib/ldb: Implement a bytes derived object for attributes py2/py3 2018-07-13 01:12:24 +02:00
pyldb.h pyldb: protect PyErr_LDB_ERROR_IS_ERR_RAISE() with do {} while(0) 2016-11-23 16:53:28 +01:00
README_gcov.txt
wscript ldb: version 1.4.1 2018-07-12 07:43:22 +02:00