Hi,
I decided to take python-ldap-2.3.13 few days ago and I made som changes to get
it work on python3.
Now I have working version for python3 (tested on Ubuntu 10.4 LTS x64 and
Debian Squeeze x64).
You can try it. It can be start point for new branche of python-ldap-py3.
I made only few tests (bind,search,del,add) - successfully.
Regards,
Dusan
diff -Nuar python-ldap-2.3.13-2.x/Lib/ldap/controls.py python-ldap-2.3.13/Lib/ldap/controls.py
--- python-ldap-2.3.13-2.x/Lib/ldap/controls.py 2009-10-30 14:20:47.000000000 +0100
+++ python-ldap-2.3.13/Lib/ldap/controls.py 2011-02-23 17:12:55.911509230 +0100
@@ -17,7 +17,7 @@
]
-from types import ClassType
+ClassType = type
import _ldap,ldap
diff -Nuar python-ldap-2.3.13-2.x/Lib/ldap/schema/models.py python-ldap-2.3.13/Lib/ldap/schema/models.py
--- python-ldap-2.3.13-2.x/Lib/ldap/schema/models.py 2011-02-19 21:51:43.000000000 +0100
+++ python-ldap-2.3.13/Lib/ldap/schema/models.py 2011-02-23 17:12:55.911509230 +0100
@@ -12,11 +12,13 @@
from ldap.schema.tokenizer import split_tokens,extract_tokens
if __debug__:
- from types import TupleType,StringType,IntType
+ TupleType = tuple
+ StringType = bytes
+ IntType = int
try:
- from types import BooleanType
+ BooleanType = bool
except ImportError:
- BooleanType = IntType
+ BooleanType = int
NOT_HUMAN_READABLE_LDAP_SYNTAXES = {
@@ -532,7 +534,7 @@
return '( %s )' % ''.join(result)
-class Entry(UserDict.UserDict):
+class Entry(UserDict):
"""
Schema-aware implementation of an LDAP entry class.
@@ -545,7 +547,7 @@
self._attrtype2keytuple = {}
self._s = schema
self.dn = dn
- UserDict.UserDict.__init__(self,{})
+ UserDict.__init__(self,{})
self.update(entry)
def _at2key(self,nameoroid):
diff -Nuar python-ldap-2.3.13-2.x/Lib/ldap/schema/subentry.py python-ldap-2.3.13/Lib/ldap/schema/subentry.py
--- python-ldap-2.3.13-2.x/Lib/ldap/schema/subentry.py 2011-02-19 21:52:14.000000000 +0100
+++ python-ldap-2.3.13/Lib/ldap/schema/subentry.py 2011-02-23 17:12:55.911509230 +0100
@@ -10,7 +10,7 @@
from ldap.schema.models import *
-from UserDict import UserDict
+from collections import UserDict
SCHEMA_CLASS_MAPPING = ldap.cidict.cidict()
SCHEMA_ATTR_MAPPING = {}
diff -Nuar python-ldap-2.3.13-2.x/Modules/berval.c python-ldap-2.3.13/Modules/berval.c
--- python-ldap-2.3.13-2.x/Modules/berval.c 2009-08-17 03:49:47.000000000 +0200
+++ python-ldap-2.3.13/Modules/berval.c 2011-02-23 17:12:55.911509230 +0100
@@ -90,7 +90,7 @@
Py_INCREF(ret);
}
else {
- ret = PyString_FromStringAndSize(bv->bv_val, bv->bv_len);
+ ret = PyBytes_FromStringAndSize(bv->bv_val, bv->bv_len);
}
return ret;
diff -Nuar python-ldap-2.3.13-2.x/Modules/constants.c python-ldap-2.3.13/Modules/constants.c
--- python-ldap-2.3.13-2.x/Modules/constants.c 2011-01-06 16:20:59.000000000 +0100
+++ python-ldap-2.3.13/Modules/constants.c 2011-02-23 17:12:55.911509230 +0100
@@ -14,7 +14,7 @@
PyObject*
LDAPconstant( int val ) {
- PyObject *i = PyInt_FromLong( val );
+ PyObject *i = PyLong_FromLong( val );
PyObject *s = PyObject_GetItem( reverse, i );
if (s == NULL) {
PyErr_Clear();
@@ -39,7 +39,7 @@
#define add_int(d, name) \
{ \
- PyObject *i = PyInt_FromLong(LDAP_##name); \
+ PyObject *i = PyLong_FromLong(LDAP_##name); \
PyDict_SetItemString( d, #name, i ); \
Py_DECREF(i); \
}
@@ -92,7 +92,7 @@
/* reversibles */
- zero = PyInt_FromLong( 0 );
+ zero = PyLong_FromLong( 0 );
PyDict_SetItem( reverse, zero, Py_None );
Py_DECREF( zero );
@@ -246,11 +246,11 @@
add_int(d,AVA_NONPRINTABLE);
/*add_int(d,OPT_ON);*/
- obj = PyInt_FromLong(1);
+ obj = PyLong_FromLong(1);
PyDict_SetItemString( d, "OPT_ON", obj );
Py_DECREF(obj);
/*add_int(d,OPT_OFF);*/
- obj = PyInt_FromLong(0);
+ obj = PyLong_FromLong(0);
PyDict_SetItemString( d, "OPT_OFF", obj );
Py_DECREF(obj);
@@ -263,42 +263,42 @@
/* author */
- author = PyString_FromString("[email protected]");
+ author = PyBytes_FromString("[email protected]");
PyDict_SetItemString(d, "__author__", author);
Py_DECREF(author);
/* add_int(d,LIBLDAP_R); */
#ifdef HAVE_LIBLDAP_R
- obj = PyInt_FromLong(1);
+ obj = PyLong_FromLong(1);
#else
- obj = PyInt_FromLong(0);
+ obj = PyLong_FromLong(0);
#endif
PyDict_SetItemString( d, "LIBLDAP_R", obj );
Py_DECREF(obj);
/* add_int(d,SASL); */
#ifdef HAVE_SASL
- obj = PyInt_FromLong(1);
+ obj = PyLong_FromLong(1);
#else
- obj = PyInt_FromLong(0);
+ obj = PyLong_FromLong(0);
#endif
PyDict_SetItemString( d, "SASL_AVAIL", obj );
Py_DECREF(obj);
/* add_int(d,TLS); */
#ifdef HAVE_TLS
- obj = PyInt_FromLong(1);
+ obj = PyLong_FromLong(1);
#else
- obj = PyInt_FromLong(0);
+ obj = PyLong_FromLong(0);
#endif
PyDict_SetItemString( d, "TLS_AVAIL", obj );
Py_DECREF(obj);
- obj = PyString_FromString(LDAP_CONTROL_PAGE_OID);
+ obj = PyBytes_FromString(LDAP_CONTROL_PAGE_OID);
PyDict_SetItemString( d, "LDAP_CONTROL_PAGE_OID", obj );
Py_DECREF(obj);
- obj = PyString_FromString(LDAP_CONTROL_VALUESRETURNFILTER);
+ obj = PyBytes_FromString(LDAP_CONTROL_VALUESRETURNFILTER);
PyDict_SetItemString( d, "LDAP_CONTROL_VALUESRETURNFILTER", obj );
Py_DECREF(obj);
diff -Nuar python-ldap-2.3.13-2.x/Modules/errors.c python-ldap-2.3.13/Modules/errors.c
--- python-ldap-2.3.13-2.x/Modules/errors.c 2009-04-30 15:03:46.000000000 +0200
+++ python-ldap-2.3.13/Modules/errors.c 2011-02-23 17:12:55.911509230 +0100
@@ -75,7 +75,7 @@
if (info == NULL)
return NULL;
- str = PyString_FromString(ldap_err2string(errnum));
+ str = PyBytes_FromString(ldap_err2string(errnum));
if (str)
PyDict_SetItemString( info, "desc", str );
Py_XDECREF(str);
@@ -83,7 +83,7 @@
if (ldap_get_option(l, LDAP_OPT_MATCHED_DN, &matched) >= 0
&& matched != NULL) {
if (*matched != '\0') {
- str = PyString_FromString(matched);
+ str = PyBytes_FromString(matched);
if (str)
PyDict_SetItemString( info, "matched", str );
Py_XDECREF(str);
@@ -92,14 +92,14 @@
}
if (errnum == LDAP_REFERRAL) {
- str = PyString_FromString(msg);
+ str = PyBytes_FromString(msg);
if (str)
PyDict_SetItemString( info, "info", str );
Py_XDECREF(str);
} else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0
&& error != NULL) {
if (error != '\0') {
- str = PyString_FromString(error);
+ str = PyBytes_FromString(error);
if (str)
PyDict_SetItemString( info, "info", str );
Py_XDECREF(str);
diff -Nuar python-ldap-2.3.13-2.x/Modules/ldapcontrol.c python-ldap-2.3.13/Modules/ldapcontrol.c
--- python-ldap-2.3.13-2.x/Modules/ldapcontrol.c 2009-10-30 14:20:47.000000000 +0100
+++ python-ldap-2.3.13/Modules/ldapcontrol.c 2011-02-23 17:12:55.911509230 +0100
@@ -103,9 +103,9 @@
berbytes.bv_len = 0;
berbytes.bv_val = NULL;
}
- else if (PyString_Check(bytes)) {
- berbytes.bv_len = PyString_Size(bytes);
- berbytes.bv_val = PyString_AsString(bytes);
+ else if (PyBytes_Check(bytes)) {
+ berbytes.bv_len = PyBytes_Size(bytes);
+ berbytes.bv_val = PyBytes_AsString(bytes);
}
else {
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("sO",
diff -Nuar python-ldap-2.3.13-2.x/Modules/ldapmodule.c python-ldap-2.3.13/Modules/ldapmodule.c
--- python-ldap-2.3.13-2.x/Modules/ldapmodule.c 2009-04-30 15:03:46.000000000 +0200
+++ python-ldap-2.3.13/Modules/ldapmodule.c 2011-02-23 17:12:55.911509230 +0100
@@ -11,7 +11,7 @@
#include "LDAPObject.h"
-DL_EXPORT(void) init_ldap(void);
+PyMODINIT_FUNC PyInit__ldap(void);
/* dummy module methods */
@@ -19,10 +19,18 @@
{ NULL, NULL }
};
+static struct PyModuleDef moduleDef = {
+ PyModuleDef_HEAD_INIT,
+ "_ldap",
+ NULL,
+ -1,
+ methods,
+};
+
/* module initialisation */
-DL_EXPORT(void)
-init_ldap()
+PyMODINIT_FUNC
+PyInit__ldap(void)
{
PyObject *m, *d;
@@ -31,7 +39,7 @@
#endif
/* Create the module and add the functions */
- m = Py_InitModule("_ldap", methods);
+ m = PyModule_Create(&moduleDef);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
@@ -46,4 +54,6 @@
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module _ldap");
+ return m;
}
+
diff -Nuar python-ldap-2.3.13-2.x/Modules/LDAPObject.c python-ldap-2.3.13/Modules/LDAPObject.c
--- python-ldap-2.3.13-2.x/Modules/LDAPObject.c 2009-10-30 14:20:47.000000000 +0100
+++ python-ldap-2.3.13/Modules/LDAPObject.c 2011-02-23 17:12:55.921409011 +0100
@@ -25,7 +25,7 @@
LDAPObject*
newLDAPObject( LDAP* l )
{
- LDAPObject* self = (LDAPObject*) PyObject_NEW(LDAPObject, &LDAP_Type);
+ LDAPObject* self = (LDAPObject*) PyObject_New(LDAPObject, &LDAP_Type);
if (self == NULL)
return NULL;
self->ldap = l;
@@ -139,7 +139,7 @@
if (list == Py_None) {
/* None indicates a NULL mod_bvals */
- } else if (PyString_Check(list)) {
+ } else if (PyBytes_Check(list)) {
/* Single string is a singleton list */
lm->mod_bvalues = PyMem_NEW(struct berval *, 2);
if (lm->mod_bvalues == NULL)
@@ -148,8 +148,8 @@
if (lm->mod_bvalues[0] == NULL)
goto nomem;
lm->mod_bvalues[1] = NULL;
- lm->mod_bvalues[0]->bv_len = PyString_Size(list);
- lm->mod_bvalues[0]->bv_val = PyString_AsString(list);
+ lm->mod_bvalues[0]->bv_len = PyBytes_Size(list);
+ lm->mod_bvalues[0]->bv_val = PyBytes_AsString(list);
} else if (PySequence_Check(list)) {
nstrs = PySequence_Length(list);
lm->mod_bvalues = PyMem_NEW(struct berval *, nstrs + 1);
@@ -163,14 +163,14 @@
item = PySequence_GetItem(list, i);
if (item == NULL)
goto error;
- if (!PyString_Check(item)) {
+ if (!PyBytes_Check(item)) {
PyErr_SetObject( PyExc_TypeError, Py_BuildValue( "sO",
"expected a string in the list", item));
Py_DECREF(item);
goto error;
}
- lm->mod_bvalues[i]->bv_len = PyString_Size(item);
- lm->mod_bvalues[i]->bv_val = PyString_AsString(item);
+ lm->mod_bvalues[i]->bv_len = PyBytes_Size(item);
+ lm->mod_bvalues[i]->bv_val = PyBytes_AsString(item);
Py_DECREF(item);
}
if (nstrs == 0)
@@ -264,7 +264,7 @@
if (attrlist == Py_None) {
/* None means a NULL attrlist */
- } else if (PyString_Check(attrlist)) {
+ } else if (PyBytes_Check(attrlist)) {
/* caught by John Benninghoff <[email protected]> */
PyErr_SetObject( PyExc_TypeError, Py_BuildValue("sO",
"expected *list* of strings, not a string", attrlist ));
@@ -280,13 +280,13 @@
item = PySequence_GetItem(attrlist, i);
if (item == NULL)
goto error;
- if (!PyString_Check(item)) {
+ if (!PyBytes_Check(item)) {
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("sO",
"expected string in list", item));
Py_DECREF(item);
goto error;
}
- attrs[i] = PyString_AsString(item);
+ attrs[i] = PyBytes_AsString(item);
Py_DECREF(item);
}
attrs[len] = NULL;
@@ -445,7 +445,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_add_ext" );
- return PyInt_FromLong(msgid);
+ return PyLong_FromLong(msgid);
}
/* ldap_simple_bind */
@@ -488,7 +488,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_simple_bind" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
@@ -567,7 +567,7 @@
if (result == NULL)
/*searching for a better error code */
return LDAP_OPERATIONS_ERROR;
- c_result = PyString_AsString(result); /*xxx Error checking?? */
+ c_result = PyBytes_AsString(result); /*xxx Error checking?? */
/* according to the sasl docs, we should malloc() the returned
string only for calls where interact->id == SASL_CB_PASS, so we
@@ -662,7 +662,7 @@
/* now we extract the sasl mechanism from the SASL Object */
mechanism = PyObject_GetAttrString(SASLObject, "mech");
if (mechanism == NULL) return NULL;
- c_mechanism = PyString_AsString(mechanism);
+ c_mechanism = PyBytes_AsString(mechanism);
Py_DECREF(mechanism);
mechanism = NULL;
@@ -685,7 +685,7 @@
if (msgid != LDAP_SUCCESS)
return LDAPerror( self->ldap, "ldap_sasl_interactive_bind_s" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
#endif
@@ -729,7 +729,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_cancel" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
#endif
@@ -775,7 +775,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_compare_ext" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
@@ -816,7 +816,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_delete_ext" );
- return PyInt_FromLong(msgid);
+ return PyLong_FromLong(msgid);
}
@@ -864,7 +864,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_modify_ext" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
@@ -908,7 +908,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_rename" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
@@ -1073,7 +1073,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_search_ext" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
@@ -1227,7 +1227,7 @@
if ( ldaperror!=LDAP_SUCCESS )
return LDAPerror( self->ldap, "ldap_passwd" );
- return PyInt_FromLong( msgid );
+ return PyLong_FromLong( msgid );
}
/* methods */
@@ -1259,14 +1259,6 @@
{ NULL, NULL }
};
-/* get attribute */
-
-static PyObject*
-getattr(LDAPObject* self, char* name)
-{
- return Py_FindMethod(methods, (PyObject*)self, name);
-}
-
/* set attribute */
static int
@@ -1276,28 +1268,44 @@
return -1;
}
-/* type entry */
-
PyTypeObject LDAP_Type = {
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- /* see http://www.python.org/doc/FAQ.html#3.24 */
- PyObject_HEAD_INIT(NULL)
-#else /* ! MS_WINDOWS */
- PyObject_HEAD_INIT(&PyType_Type)
-#endif /* MS_WINDOWS */
- 0, /*ob_size*/
- "LDAP", /*tp_name*/
- sizeof(LDAPObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)getattr, /*tp_getattr*/
- (setattrfunc)setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "LDAP", /* Name of this type */
+ sizeof(LDAPObject), /* Basic object size */
+ 0, /* Item size for varobject */
+ (destructor)dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ (setattrfunc)setattr, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
+
diff -Nuar python-ldap-2.3.13-2.x/Modules/message.c python-ldap-2.3.13/Modules/message.c
--- python-ldap-2.3.13-2.x/Modules/message.c 2009-10-30 14:20:47.000000000 +0100
+++ python-ldap-2.3.13/Modules/message.c 2011-02-23 17:12:55.921409011 +0100
@@ -143,7 +143,7 @@
if (refs) {
Py_ssize_t i;
for (i=0; refs[i] != NULL; i++) {
- PyObject *refstr = PyString_FromString(refs[i]);
+ PyObject *refstr = PyBytes_FromString(refs[i]);
PyList_Append(reflist, refstr);
Py_DECREF(refstr);
}
diff -Nuar python-ldap-2.3.13-2.x/Modules/options.c python-ldap-2.3.13/Modules/options.c
--- python-ldap-2.3.13-2.x/Modules/options.c 2011-01-06 16:20:59.000000000 +0100
+++ python-ldap-2.3.13/Modules/options.c 2011-02-23 17:12:55.921409011 +0100
@@ -205,7 +205,7 @@
extensions = PyTuple_New(num_extensions);
for (i = 0; i < num_extensions; i++)
PyTuple_SET_ITEM(extensions, i,
- PyString_FromString(apiinfo.ldapai_extensions[i]));
+ PyBytes_FromString(apiinfo.ldapai_extensions[i]));
/* return api info as a dictionary */
v = Py_BuildValue("{s:i, s:i, s:i, s:s, s:i, s:O}",
@@ -271,7 +271,7 @@
if (self) LDAP_END_ALLOW_THREADS(self);
if (res != LDAP_OPT_SUCCESS)
return option_error(res, "ldap_get_option");
- return PyInt_FromLong(intval);
+ return PyLong_FromLong(intval);
case LDAP_OPT_HOST_NAME:
case LDAP_OPT_URI:
@@ -312,7 +312,7 @@
Py_INCREF(Py_None);
return Py_None;
}
- v = PyString_FromString(strval);
+ v = PyBytes_FromString(strval);
ldap_memfree(strval);
return v;
diff -Nuar python-ldap-2.3.13-2.x/Modules/schema.c python-ldap-2.3.13/Modules/schema.c
--- python-ldap-2.3.13-2.x/Modules/schema.c 2009-04-30 15:03:46.000000000 +0200
+++ python-ldap-2.3.13/Modules/schema.c 2011-02-23 17:12:55.921409011 +0100
@@ -22,7 +22,7 @@
py_list = PyList_New(count);
count = 0;
for (s=string_array; *s != 0; s++){
- PyList_SetItem(py_list, count, PyString_FromString(*s));
+ PyList_SetItem(py_list, count, PyBytes_FromString(*s));
count++;
}
} else py_list=PyList_New(0);
@@ -52,7 +52,7 @@
for (e = extensions; *e !=0; e++) {
item_tuple = PyTuple_New(2);
PyTuple_SetItem(item_tuple, 0,
- PyString_FromString((*e)->lsei_name));
+ PyBytes_FromString((*e)->lsei_name));
PyTuple_SetItem(item_tuple, 1,
c_string_array_to_python((*e)->lsei_values));
PyList_SetItem(py_list, count, item_tuple);
@@ -89,7 +89,7 @@
return NULL;
o = ldap_str2objectclass( oc_string, &ret, &errp, flag);
if (ret) {
- py_ret = PyInt_FromLong(ret);
+ py_ret = PyLong_FromLong(ret);
return py_ret;
}
@@ -98,16 +98,16 @@
oc_at_oids_must = c_string_array_to_python(o->oc_at_oids_must);
oc_at_oids_may = c_string_array_to_python(o->oc_at_oids_may);
py_ret = PyList_New(9);
- PyList_SetItem(py_ret, 0, PyString_FromString(o->oc_oid));
+ PyList_SetItem(py_ret, 0, PyBytes_FromString(o->oc_oid));
PyList_SetItem(py_ret, 1, oc_names);
if (o->oc_desc) {
- PyList_SetItem(py_ret, 2, PyString_FromString(o->oc_desc));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(o->oc_desc));
} else {
- PyList_SetItem(py_ret, 2, PyString_FromString(""));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(""));
}
- PyList_SetItem(py_ret, 3, PyInt_FromLong(o->oc_obsolete));
+ PyList_SetItem(py_ret, 3, PyLong_FromLong(o->oc_obsolete));
PyList_SetItem(py_ret, 4, oc_sup_oids);
- PyList_SetItem(py_ret, 5, PyInt_FromLong(o->oc_kind));
+ PyList_SetItem(py_ret, 5, PyLong_FromLong(o->oc_kind));
PyList_SetItem(py_ret, 6, oc_at_oids_must);
PyList_SetItem(py_ret, 7, oc_at_oids_may);
@@ -136,50 +136,50 @@
return NULL;
a = ldap_str2attributetype( at_string, &ret, &errp, flag);
if (ret) {
- py_ret = PyInt_FromLong(ret);
+ py_ret = PyLong_FromLong(ret);
return py_ret;
}
py_ret = PyList_New(15);
- PyList_SetItem(py_ret, 0, PyString_FromString(a->at_oid));
+ PyList_SetItem(py_ret, 0, PyBytes_FromString(a->at_oid));
at_names = c_string_array_to_python(a->at_names);
PyList_SetItem(py_ret, 1, at_names);
if (a->at_desc) {
- PyList_SetItem(py_ret, 2, PyString_FromString(a->at_desc));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(a->at_desc));
} else {
- PyList_SetItem(py_ret, 2, PyString_FromString(""));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(""));
}
- PyList_SetItem(py_ret, 3, PyInt_FromLong(a->at_obsolete));
+ PyList_SetItem(py_ret, 3, PyLong_FromLong(a->at_obsolete));
if (a->at_sup_oid) {
- PyList_SetItem(py_ret, 4, PyString_FromString(a->at_sup_oid));
+ PyList_SetItem(py_ret, 4, PyBytes_FromString(a->at_sup_oid));
} else {
- PyList_SetItem(py_ret, 4, PyString_FromString(""));
+ PyList_SetItem(py_ret, 4, PyBytes_FromString(""));
}
if (a->at_equality_oid) {
- PyList_SetItem(py_ret, 5, PyString_FromString(a->at_equality_oid));
+ PyList_SetItem(py_ret, 5, PyBytes_FromString(a->at_equality_oid));
} else {
- PyList_SetItem(py_ret, 5, PyString_FromString(""));
+ PyList_SetItem(py_ret, 5, PyBytes_FromString(""));
}
if (a->at_ordering_oid) {
- PyList_SetItem(py_ret, 6, PyString_FromString(a->at_ordering_oid));
+ PyList_SetItem(py_ret, 6, PyBytes_FromString(a->at_ordering_oid));
} else {
- PyList_SetItem(py_ret, 6, PyString_FromString(""));
+ PyList_SetItem(py_ret, 6, PyBytes_FromString(""));
}
if (a->at_substr_oid) {
- PyList_SetItem(py_ret, 7, PyString_FromString(a->at_substr_oid));
+ PyList_SetItem(py_ret, 7, PyBytes_FromString(a->at_substr_oid));
} else {
- PyList_SetItem(py_ret, 7, PyString_FromString(""));
+ PyList_SetItem(py_ret, 7, PyBytes_FromString(""));
}
if (a->at_syntax_oid) {
- PyList_SetItem(py_ret, 8, PyString_FromString(a->at_syntax_oid));
+ PyList_SetItem(py_ret, 8, PyBytes_FromString(a->at_syntax_oid));
} else {
- PyList_SetItem(py_ret, 8, PyString_FromString(""));
+ PyList_SetItem(py_ret, 8, PyBytes_FromString(""));
}
- PyList_SetItem(py_ret, 9, PyInt_FromLong(a->at_syntax_len));
- PyList_SetItem(py_ret,10, PyInt_FromLong(a->at_single_value));
- PyList_SetItem(py_ret,11, PyInt_FromLong(a->at_collective));
- PyList_SetItem(py_ret,12, PyInt_FromLong(a->at_no_user_mod));
- PyList_SetItem(py_ret,13, PyInt_FromLong(a->at_usage));
+ PyList_SetItem(py_ret, 9, PyLong_FromLong(a->at_syntax_len));
+ PyList_SetItem(py_ret,10, PyLong_FromLong(a->at_single_value));
+ PyList_SetItem(py_ret,11, PyLong_FromLong(a->at_collective));
+ PyList_SetItem(py_ret,12, PyLong_FromLong(a->at_no_user_mod));
+ PyList_SetItem(py_ret,13, PyLong_FromLong(a->at_usage));
PyList_SetItem(py_ret, 14,
schema_extension_to_python(a->at_extensions));
@@ -204,17 +204,17 @@
return NULL;
s = ldap_str2syntax(syn_string, &ret, &errp, flag);
if (ret) {
- py_ret = PyInt_FromLong(ret);
+ py_ret = PyLong_FromLong(ret);
return py_ret;
}
py_ret = PyList_New(4);
- PyList_SetItem(py_ret, 0, PyString_FromString(s->syn_oid));
+ PyList_SetItem(py_ret, 0, PyBytes_FromString(s->syn_oid));
syn_names = c_string_array_to_python(s->syn_names);
PyList_SetItem(py_ret, 1, syn_names);
if (s->syn_desc) {
- PyList_SetItem(py_ret, 2, PyString_FromString(s->syn_desc));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(s->syn_desc));
} else {
- PyList_SetItem(py_ret, 2, PyString_FromString(""));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(""));
}
PyList_SetItem(py_ret, 3,
schema_extension_to_python(s->syn_extensions));
@@ -238,23 +238,23 @@
return NULL;
m = ldap_str2matchingrule(mr_string, &ret, &errp, flag);
if (ret) {
- py_ret = PyInt_FromLong(ret);
+ py_ret = PyLong_FromLong(ret);
return py_ret;
}
py_ret = PyList_New(6);
- PyList_SetItem(py_ret, 0, PyString_FromString(m->mr_oid));
+ PyList_SetItem(py_ret, 0, PyBytes_FromString(m->mr_oid));
mr_names = c_string_array_to_python(m->mr_names);
PyList_SetItem(py_ret, 1, mr_names);
if (m->mr_desc) {
- PyList_SetItem(py_ret, 2, PyString_FromString(m->mr_desc));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(m->mr_desc));
} else {
- PyList_SetItem(py_ret, 2, PyString_FromString(""));
+ PyList_SetItem(py_ret, 2, PyBytes_FromString(""));
}
- PyList_SetItem(py_ret, 3, PyInt_FromLong(m->mr_obsolete));
+ PyList_SetItem(py_ret, 3, PyLong_FromLong(m->mr_obsolete));
if (m->mr_syntax_oid) {
- PyList_SetItem(py_ret, 4, PyString_FromString(m->mr_syntax_oid));
+ PyList_SetItem(py_ret, 4, PyBytes_FromString(m->mr_syntax_oid));
} else {
- PyList_SetItem(py_ret, 4, PyString_FromString(""));
+ PyList_SetItem(py_ret, 4, PyBytes_FromString(""));
}
PyList_SetItem(py_ret, 5,
schema_extension_to_python(m->mr_extensions));
diff -Nuar python-ldap-2.3.13-2.x/Modules/version.c python-ldap-2.3.13/Modules/version.c
--- python-ldap-2.3.13-2.x/Modules/version.c 2009-04-30 15:03:46.000000000 +0200
+++ python-ldap-2.3.13/Modules/version.c 2011-02-23 17:12:55.921409011 +0100
@@ -14,7 +14,7 @@
{
PyObject *version;
- version = PyString_FromString(version_str);
+ version = PyBytes_FromString(version_str);
PyDict_SetItemString( d, "__version__", version );
Py_DECREF(version);
}
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev