Skip to content

Commit

Permalink
adjust PyInit for _psutil_sunosù.c
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 19, 2024
1 parent d77664c commit 6843ee1
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions psutil/_psutil_sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include "arch/solaris/environ.h"

#define PSUTIL_TV2DOUBLE(t) (((t).tv_nsec * 0.000000001) + (t).tv_sec)
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
#define INITERROR return NULL


/*
Expand Down Expand Up @@ -1671,13 +1673,6 @@ struct module_state {
PyObject *error;
};

#if PY_MAJOR_VERSION >= 3
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
#else
#define GETSTATE(m) (&_state)
#endif

#if PY_MAJOR_VERSION >= 3

static int
psutil_sunos_traverse(PyObject *m, visitproc visit, void *arg) {
Expand All @@ -1703,21 +1698,10 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__psutil_sunos(void)

#else
#define INITERROR return

void init_psutil_sunos(void)
#endif
{
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC
PyInit__psutil_sunos(void) {
PyObject *module = PyModule_Create(&moduledef);
#else
PyObject *module = Py_InitModule("_psutil_sunos", PsutilMethods);
#endif
if (module == NULL)
INITERROR;

Expand Down Expand Up @@ -1766,7 +1750,6 @@ void init_psutil_sunos(void)

if (module == NULL)
INITERROR;
#if PY_MAJOR_VERSION >= 3

return module;
#endif
}

0 comments on commit 6843ee1

Please sign in to comment.