Skip to content

Commit

Permalink
[fix] Python 3 module init, teardown methods
Browse files Browse the repository at this point in the history
  • Loading branch information
albarrentine committed Feb 12, 2016
1 parent a6c22f0 commit bc8ad67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions postal/pyexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static PyObject *py_expand(PyObject *self, PyObject *args, PyObject *keywords) {

language = NULL;

#if IS_PY3K
#ifdef IS_PY3K

if (PyBytes_Check(item)) {
language = PyBytes_AsString(item);
Expand Down Expand Up @@ -258,7 +258,7 @@ static int expand_traverse(PyObject *m, visitproc visit, void *arg) {

static int expand_clear(PyObject *m) {
Py_CLEAR(GETSTATE(m)->error);
libpostal_language_classifier_teardown();
libpostal_teardown_language_classifier();
libpostal_teardown();
return 0;
}
Expand All @@ -278,14 +278,15 @@ static struct PyModuleDef module_def = {
#define INITERROR return NULL

PyObject *
PyInit_expand(void) {
PyInit__expand(void) {

#else

#define INITERROR return

void cleanup_libpostal(void) {
libpostal_teardown();
libpostal_teardown_language_classifier();
}

void
Expand Down Expand Up @@ -334,7 +335,7 @@ init_expand(void) {
Py_AtExit(&cleanup_libpostal);
#endif

#if IS_PY3K
#ifdef IS_PY3K
return module;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion postal/pyparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static struct PyModuleDef module_def = {
#define INITERROR return NULL

PyObject *
PyInit_parser(void) {
PyInit__parser(void) {
#else

#define INITERROR return
Expand Down

0 comments on commit bc8ad67

Please sign in to comment.