Skip to content

Commit 3bae48d

Browse files
committed
Fixes helpers C extension for Python 2.7
1 parent cfa2167 commit 3bae48d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pendulum/_extensions/_helpers.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,15 @@ init_helpers(void)
989989
#if PY_MAJOR_VERSION >= 3
990990
module = PyModule_Create(&moduledef);
991991
#else
992-
module = Py_InitModule("_helpers", helpers_methods, NULL);
992+
module = Py_InitModule3("_helpers", helpers_methods, NULL);
993993
#endif
994994

995995
if (module == NULL)
996+
#if PY_MAJOR_VERSION >= 3
996997
return NULL;
998+
#else
999+
return;
1000+
#endif
9971001

9981002
FixedOffset_type.tp_new = PyType_GenericNew;
9991003
FixedOffset_type.tp_base = PyDateTimeAPI->TZInfoType;
@@ -1002,12 +1006,17 @@ init_helpers(void)
10021006
FixedOffset_type.tp_init = (initproc)FixedOffset_init;
10031007

10041008
if (PyType_Ready(&FixedOffset_type) < 0)
1009+
#if PY_MAJOR_VERSION >= 3
10051010
return NULL;
1011+
#else
1012+
return;
1013+
#endif
10061014

10071015
Py_INCREF(&FixedOffset_type);
10081016

10091017
PyModule_AddObject(module, "TZFixedOffset", (PyObject *)&FixedOffset_type);
1010-
1018+
#if PY_MAJOR_VERSION >= 3
10111019
return module;
1020+
#endif
10121021
}
10131022
#endif

0 commit comments

Comments
 (0)