Use PyInt on Python 2.x
This commit is contained in:
parent
126a543b27
commit
f976b94ac5
|
@ -446,7 +446,7 @@ l_ldap_add_ext( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_add_ext" );
|
||||
|
||||
return PyLong_FromLong(msgid);
|
||||
return PyInt_FromLong(msgid);
|
||||
}
|
||||
|
||||
/* ldap_simple_bind */
|
||||
|
@ -489,7 +489,7 @@ l_ldap_simple_bind( LDAPObject* self, PyObject* args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_simple_bind" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -667,7 +667,7 @@ l_ldap_sasl_bind_s( LDAPObject* self, PyObject* args )
|
|||
return PyBytes_FromStringAndSize( servercred->bv_val, servercred->bv_len );
|
||||
} else if (ldaperror != LDAP_SUCCESS)
|
||||
return LDAPerror( self->ldap, "l_ldap_sasl_bind_s" );
|
||||
return PyLong_FromLong( ldaperror );
|
||||
return PyInt_FromLong( ldaperror );
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
|
@ -739,7 +739,7 @@ l_ldap_sasl_interactive_bind_s( LDAPObject* self, PyObject* args )
|
|||
|
||||
if (msgid != LDAP_SUCCESS)
|
||||
return LDAPerror( self->ldap, "ldap_sasl_interactive_bind_s" );
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -783,7 +783,7 @@ l_ldap_cancel( LDAPObject* self, PyObject* args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_cancel" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -829,7 +829,7 @@ l_ldap_compare_ext( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_compare_ext" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -870,7 +870,7 @@ l_ldap_delete_ext( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_delete_ext" );
|
||||
|
||||
return PyLong_FromLong(msgid);
|
||||
return PyInt_FromLong(msgid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -918,7 +918,7 @@ l_ldap_modify_ext( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_modify_ext" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -962,7 +962,7 @@ l_ldap_rename( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_rename" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1157,7 +1157,7 @@ l_ldap_search_ext( LDAPObject* self, PyObject* args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_search_ext" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1311,7 +1311,7 @@ l_ldap_passwd( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_passwd" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1359,7 +1359,7 @@ l_ldap_extended_operation( LDAPObject* self, PyObject *args )
|
|||
if ( ldaperror!=LDAP_SUCCESS )
|
||||
return LDAPerror( self->ldap, "ldap_extended_operation" );
|
||||
|
||||
return PyLong_FromLong( msgid );
|
||||
return PyInt_FromLong( msgid );
|
||||
}
|
||||
|
||||
/* methods */
|
||||
|
|
|
@ -37,10 +37,14 @@ void LDAPadd_methods( PyObject*d, PyMethodDef*methods );
|
|||
|
||||
/* Py2/3 compatibility */
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
/* Python 2.x */
|
||||
#define PyBytes_Check PyString_Check
|
||||
#define PyBytes_Size PyString_Size
|
||||
#define PyBytes_AsString PyString_AsString
|
||||
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
#else
|
||||
/* Python 3.x */
|
||||
#define PyInt_FromLong PyLong_FromLong
|
||||
#endif
|
||||
|
||||
#endif /* __h_common_ */
|
||||
|
|
|
@ -14,7 +14,7 @@ static PyObject* forward;
|
|||
|
||||
PyObject*
|
||||
LDAPconstant( int val ) {
|
||||
PyObject *i = PyLong_FromLong( val );
|
||||
PyObject *i = PyInt_FromLong( val );
|
||||
PyObject *s = PyObject_GetItem( reverse, i );
|
||||
if (s == NULL) {
|
||||
PyErr_Clear();
|
||||
|
@ -39,7 +39,7 @@ LDAPinit_constants( PyObject* d )
|
|||
|
||||
#define add_int(d, name) \
|
||||
{ \
|
||||
PyObject *i = PyLong_FromLong(LDAP_##name); \
|
||||
PyObject *i = PyInt_FromLong(LDAP_##name); \
|
||||
PyDict_SetItemString( d, #name, i ); \
|
||||
Py_DECREF(i); \
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ LDAPinit_constants( PyObject* d )
|
|||
|
||||
/* reversibles */
|
||||
|
||||
zero = PyLong_FromLong( 0 );
|
||||
zero = PyInt_FromLong( 0 );
|
||||
PyDict_SetItem( reverse, zero, Py_None );
|
||||
Py_DECREF( zero );
|
||||
|
||||
|
@ -266,11 +266,11 @@ LDAPinit_constants( PyObject* d )
|
|||
add_int(d,AVA_NONPRINTABLE);
|
||||
|
||||
/*add_int(d,OPT_ON);*/
|
||||
obj = PyLong_FromLong(1);
|
||||
obj = PyInt_FromLong(1);
|
||||
PyDict_SetItemString( d, "OPT_ON", obj );
|
||||
Py_DECREF(obj);
|
||||
/*add_int(d,OPT_OFF);*/
|
||||
obj = PyLong_FromLong(0);
|
||||
obj = PyInt_FromLong(0);
|
||||
PyDict_SetItemString( d, "OPT_OFF", obj );
|
||||
Py_DECREF(obj);
|
||||
|
||||
|
@ -289,27 +289,27 @@ LDAPinit_constants( PyObject* d )
|
|||
|
||||
/* add_int(d,LIBLDAP_R); */
|
||||
#ifdef HAVE_LIBLDAP_R
|
||||
obj = PyLong_FromLong(1);
|
||||
obj = PyInt_FromLong(1);
|
||||
#else
|
||||
obj = PyLong_FromLong(0);
|
||||
obj = PyInt_FromLong(0);
|
||||
#endif
|
||||
PyDict_SetItemString( d, "LIBLDAP_R", obj );
|
||||
Py_DECREF(obj);
|
||||
|
||||
/* add_int(d,SASL); */
|
||||
#ifdef HAVE_SASL
|
||||
obj = PyLong_FromLong(1);
|
||||
obj = PyInt_FromLong(1);
|
||||
#else
|
||||
obj = PyLong_FromLong(0);
|
||||
obj = PyInt_FromLong(0);
|
||||
#endif
|
||||
PyDict_SetItemString( d, "SASL_AVAIL", obj );
|
||||
Py_DECREF(obj);
|
||||
|
||||
/* add_int(d,TLS); */
|
||||
#ifdef HAVE_TLS
|
||||
obj = PyLong_FromLong(1);
|
||||
obj = PyInt_FromLong(1);
|
||||
#else
|
||||
obj = PyLong_FromLong(0);
|
||||
obj = PyInt_FromLong(0);
|
||||
#endif
|
||||
PyDict_SetItemString( d, "TLS_AVAIL", obj );
|
||||
Py_DECREF(obj);
|
||||
|
|
|
@ -272,7 +272,7 @@ LDAP_get_option(LDAPObject *self, int option)
|
|||
if (self) LDAP_END_ALLOW_THREADS(self);
|
||||
if (res != LDAP_OPT_SUCCESS)
|
||||
return option_error(res, "ldap_get_option");
|
||||
return PyLong_FromLong(intval);
|
||||
return PyInt_FromLong(intval);
|
||||
|
||||
case LDAP_OPT_HOST_NAME:
|
||||
case LDAP_OPT_URI:
|
||||
|
|
|
@ -89,7 +89,7 @@ l_ldap_str2objectclass(PyObject* self, PyObject *args)
|
|||
return NULL;
|
||||
o = ldap_str2objectclass( oc_string, &ret, &errp, flag);
|
||||
if (ret) {
|
||||
py_ret = PyLong_FromLong(ret);
|
||||
py_ret = PyInt_FromLong(ret);
|
||||
return py_ret;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ l_ldap_str2objectclass(PyObject* self, PyObject *args)
|
|||
} else {
|
||||
PyList_SetItem(py_ret, 2, PyUnicode_FromString(""));
|
||||
}
|
||||
PyList_SetItem(py_ret, 3, PyLong_FromLong(o->oc_obsolete));
|
||||
PyList_SetItem(py_ret, 3, PyInt_FromLong(o->oc_obsolete));
|
||||
PyList_SetItem(py_ret, 4, oc_sup_oids);
|
||||
PyList_SetItem(py_ret, 5, PyLong_FromLong(o->oc_kind));
|
||||
PyList_SetItem(py_ret, 5, PyInt_FromLong(o->oc_kind));
|
||||
PyList_SetItem(py_ret, 6, oc_at_oids_must);
|
||||
PyList_SetItem(py_ret, 7, oc_at_oids_may);
|
||||
|
||||
|
@ -136,7 +136,7 @@ l_ldap_str2attributetype(PyObject* self, PyObject *args)
|
|||
return NULL;
|
||||
a = ldap_str2attributetype( at_string, &ret, &errp, flag);
|
||||
if (ret) {
|
||||
py_ret = PyLong_FromLong(ret);
|
||||
py_ret = PyInt_FromLong(ret);
|
||||
return py_ret;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ l_ldap_str2attributetype(PyObject* self, PyObject *args)
|
|||
} else {
|
||||
PyList_SetItem(py_ret, 2, PyUnicode_FromString(""));
|
||||
}
|
||||
PyList_SetItem(py_ret, 3, PyLong_FromLong(a->at_obsolete));
|
||||
PyList_SetItem(py_ret, 3, PyInt_FromLong(a->at_obsolete));
|
||||
if (a->at_sup_oid) {
|
||||
PyList_SetItem(py_ret, 4, PyUnicode_FromString(a->at_sup_oid));
|
||||
} else {
|
||||
|
@ -175,11 +175,11 @@ l_ldap_str2attributetype(PyObject* self, PyObject *args)
|
|||
} else {
|
||||
PyList_SetItem(py_ret, 8, PyUnicode_FromString(""));
|
||||
}
|
||||
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, 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, 14,
|
||||
schema_extension_to_python(a->at_extensions));
|
||||
|
@ -204,7 +204,7 @@ l_ldap_str2syntax(PyObject* self, PyObject *args)
|
|||
return NULL;
|
||||
s = ldap_str2syntax(syn_string, &ret, &errp, flag);
|
||||
if (ret) {
|
||||
py_ret = PyLong_FromLong(ret);
|
||||
py_ret = PyInt_FromLong(ret);
|
||||
return py_ret;
|
||||
}
|
||||
py_ret = PyList_New(4);
|
||||
|
@ -238,7 +238,7 @@ l_ldap_str2matchingrule(PyObject* self, PyObject *args)
|
|||
return NULL;
|
||||
m = ldap_str2matchingrule(mr_string, &ret, &errp, flag);
|
||||
if (ret) {
|
||||
py_ret = PyLong_FromLong(ret);
|
||||
py_ret = PyInt_FromLong(ret);
|
||||
return py_ret;
|
||||
}
|
||||
py_ret = PyList_New(6);
|
||||
|
@ -250,7 +250,7 @@ l_ldap_str2matchingrule(PyObject* self, PyObject *args)
|
|||
} else {
|
||||
PyList_SetItem(py_ret, 2, PyUnicode_FromString(""));
|
||||
}
|
||||
PyList_SetItem(py_ret, 3, PyLong_FromLong(m->mr_obsolete));
|
||||
PyList_SetItem(py_ret, 3, PyInt_FromLong(m->mr_obsolete));
|
||||
if (m->mr_syntax_oid) {
|
||||
PyList_SetItem(py_ret, 4, PyUnicode_FromString(m->mr_syntax_oid));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue