Skip to content

Commit

Permalink
Use standard PyVarObject_HEAD_INIT() call
Browse files Browse the repository at this point in the history
PyType_Ready() takes care of the base type for us. Also check PyType_Ready()
result for error.

https://github.com/python-ldap/python-ldap/pull/47
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and Petr Viktorin committed Nov 29, 2017
1 parent 5328164 commit ece4738
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 0 additions & 5 deletions Modules/LDAPObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,12 +1434,7 @@ static PyMethodDef methods[] = {
/* type entry */

PyTypeObject LDAP_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
/* see http://www.python.org/doc/FAQ.html#3.24 */
PyVarObject_HEAD_INIT(NULL, 0)
#else /* ! MS_WINDOWS */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#endif /* MS_WINDOWS */
"LDAP", /*tp_name*/
sizeof(LDAPObject), /*tp_basicsize*/
0, /*tp_itemsize*/
Expand Down
8 changes: 3 additions & 5 deletions Modules/ldapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ PyObject* init_ldap_module()
{
PyObject *m, *d;

#if defined(MS_WINDOWS) || defined(__CYGWIN__)
LDAP_Type.ob_type = &PyType_Type;
#endif
/* Initialize LDAP class */
if (PyType_Ready(&LDAP_Type) < 0)
return NULL;

/* Create the module and add the functions */
#if PY_MAJOR_VERSION >= 3
Expand All @@ -59,8 +59,6 @@ PyObject* init_ldap_module()
m = Py_InitModule("_ldap", methods);
#endif

PyType_Ready(&LDAP_Type);

/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);

Expand Down

0 comments on commit ece4738

Please sign in to comment.