russjancewicz/python-kadmin — pull request #18 by aebruno (2014-08-19 15:33:43+00:00)
Title: Add PyDateTime_IMPORT to module initialization function.

Was experiencing segfaults when accessing datetime fields on the
PyKAdminPrincipalObject, for example, calls to function
PyKAdminPrincipal_get_expire(..) resulted in a segfault.

Example code resulting in segfault:

import kadmin

kadm = kadmin.init_with_keytab("user@example.com", "/path/to/keytab")
princ = kadm.get_principal("user@example.com")
print princ.expire

However, if imported datetime module first, all is well:

import kadmin
import datetime

kadm = kadmin.init_with_keytab("user@example.com", "/path/to/keytab")
princ = kadm.get_principal("user@example.com")
print princ.expire

This suggested datetime wasn't being initialized properly? Adding this
patch to ensure Py_DateTime is initialized as part of the module
initialization fixed the segfaults.