Skip to content

Build documentation without the compiled extension #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 27, 2017
Prev Previous commit
Next Next commit
Modules: Write out error checking in constants.c
  • Loading branch information
encukou committed Nov 27, 2017
commit a3675965499f3a939f7fd6848b2506d2e4ffdd46
5 changes: 2 additions & 3 deletions Lib/ldap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ class Feature(Constant):
c_template = '\n'.join([
'',
'#ifdef {self.c_feature}',
'result = PyModule_AddIntConstant(m, "{self.name}", 1);',
'if (PyModule_AddIntConstant(m, "{self.name}", 1) != 0) return -1;',
'#else',
'result = PyModule_AddIntConstant(m, "{self.name}", 0);',
'if (PyModule_AddIntConstant(m, "{self.name}", 0) != 0) return -1;',
'#endif',
'check_result();',
'',
])

Expand Down
30 changes: 8 additions & 22 deletions Modules/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,11 @@ int
LDAPinit_constants( PyObject* m )
{
PyObject *exc;
int result;

#define check_result() { \
if (result != 0) return -1; \
}

/* simple constants */

result = PyModule_AddIntConstant(m, "OPT_ON", 1);
check_result();
result = PyModule_AddIntConstant(m, "OPT_OFF", 0);
check_result();
if (PyModule_AddIntConstant(m, "OPT_ON", 1) != 0) return -1;
if (PyModule_AddIntConstant(m, "OPT_OFF", 0) != 0) return -1;

/* exceptions */

Expand All @@ -151,36 +144,29 @@ LDAPinit_constants( PyObject* m )
return -1;
}

result = PyModule_AddObject(m, "LDAPError", LDAPexception_class);
check_result();
if (PyModule_AddObject(m, "LDAPError", LDAPexception_class) != 0) return -1;
Py_INCREF(LDAPexception_class);

/* XXX - backward compatibility with pre-1.8 */
result = PyModule_AddObject(m, "error", LDAPexception_class);
check_result();
if (PyModule_AddObject(m, "error", LDAPexception_class) != 0) return -1;
Py_INCREF(LDAPexception_class);

/* Generated constants -- see Lib/ldap/constants.py */

#define seterrobj2(n, o) \
PyModule_AddObject(m, #n, (errobjects[LDAP_##n+LDAP_ERROR_OFFSET] = o))

#define add_err(n) { \
exc = PyErr_NewException("ldap." #n, LDAPexception_class, NULL); \
if (exc == NULL) return -1; \
result = seterrobj2(n, exc); \
check_result(); \
errobjects[LDAP_##n+LDAP_ERROR_OFFSET] = exc; \
if (PyModule_AddObject(m, #n, exc) != 0) return -1; \
Py_INCREF(exc); \
}

#define add_int(n) { \
result = PyModule_AddIntConstant(m, #n, LDAP_##n); \
check_result(); \
if (PyModule_AddIntConstant(m, #n, LDAP_##n) != 0) return -1; \
}

#define add_string(n) { \
result = PyModule_AddStringConstant(m, #n, LDAP_##n); \
check_result(); \
if (PyModule_AddStringConstant(m, #n, LDAP_##n) != 0) return -1; \
}

#include "constants_generated.h"
Expand Down
15 changes: 6 additions & 9 deletions Modules/constants_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,24 @@ add_int(URL_ERR_BADSCOPE);
add_int(URL_ERR_MEM);

#ifdef HAVE_LIBLDAP_R
result = PyModule_AddIntConstant(m, "LIBLDAP_R", 1);
if (PyModule_AddIntConstant(m, "LIBLDAP_R", 1) != 0) return -1;
#else
result = PyModule_AddIntConstant(m, "LIBLDAP_R", 0);
if (PyModule_AddIntConstant(m, "LIBLDAP_R", 0) != 0) return -1;
#endif
check_result();


#ifdef HAVE_SASL
result = PyModule_AddIntConstant(m, "SASL_AVAIL", 1);
if (PyModule_AddIntConstant(m, "SASL_AVAIL", 1) != 0) return -1;
#else
result = PyModule_AddIntConstant(m, "SASL_AVAIL", 0);
if (PyModule_AddIntConstant(m, "SASL_AVAIL", 0) != 0) return -1;
#endif
check_result();


#ifdef HAVE_TLS
result = PyModule_AddIntConstant(m, "TLS_AVAIL", 1);
if (PyModule_AddIntConstant(m, "TLS_AVAIL", 1) != 0) return -1;
#else
result = PyModule_AddIntConstant(m, "TLS_AVAIL", 0);
if (PyModule_AddIntConstant(m, "TLS_AVAIL", 0) != 0) return -1;
#endif
check_result();

add_string(CONTROL_MANAGEDSAIT);
add_string(CONTROL_PROXY_AUTHZ);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy