Skip to content

Commit

Permalink
python.h & python_console.i remove version test
Browse files Browse the repository at this point in the history
3.9 should work ok with the new syntax
  • Loading branch information
Huevos committed Feb 8, 2022
1 parent 76197b7 commit 98a9b41
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
34 changes: 0 additions & 34 deletions lib/python/python.h
Expand Up @@ -6,9 +6,7 @@

#include <string>
#include <lib/base/object.h>
#if PY_VERSION_HEX >= 0x030a0000
#define PY_SSIZE_T_CLEAN 1
#endif
#include "Python.h"

#if !defined(SKIP_PART1) && !defined(SWIG)
Expand Down Expand Up @@ -225,20 +223,12 @@ inline void Impl_Py_XINCREF(const char* file, int line, const ePyObject &obj)

inline ePyObject Impl_PyTuple_New(const char* file, int line, int elements=0)
{
#if PY_VERSION_HEX >= 0x030a0000
return ePyObject(PyTuple_New((Py_ssize_t)elements), file, line);
#else
return ePyObject(PyTuple_New(elements), file, line);
#endif
}

inline ePyObject Impl_PyList_New(const char* file, int line, int elements=0)
{
#if PY_VERSION_HEX >= 0x030a0000
return ePyObject(PyList_New((Py_ssize_t)elements), file, line);
#else
return ePyObject(PyList_New(elements), file, line);
#endif
}

inline ePyObject Impl_PyDict_New(const char* file, int line)
Expand Down Expand Up @@ -286,20 +276,12 @@ inline ePyObject Impl_PyLong_FromUnsignedLongLong(const char* file, int line, un

inline ePyObject Impl_PyList_GET_ITEM(const char *file, int line, ePyObject list, unsigned int pos)
{
#if PY_VERSION_HEX >= 0x030a0000
return ePyObject(PyList_GET_ITEM(list, (Py_ssize_t)pos), file, line);
#else
return ePyObject(PyList_GET_ITEM(list, pos), file, line);
#endif
}

inline ePyObject Impl_PyTuple_GET_ITEM(const char *file, int line, ePyObject list, unsigned int pos)
{
#if PY_VERSION_HEX >= 0x030a0000
return ePyObject(PyTuple_GET_ITEM(list, (Py_ssize_t)pos), file, line);
#else
return ePyObject(PyTuple_GET_ITEM(list, pos), file, line);
#endif
}
#else
inline void Impl_Py_DECREF(const ePyObject &obj)
Expand All @@ -326,20 +308,12 @@ inline void Impl_Py_XINCREF(const ePyObject &obj)

inline ePyObject Impl_PyTuple_New(int elements=0)
{
#if PY_VERSION_HEX >= 0x030a0000
return PyTuple_New((Py_ssize_t)elements);
#else
return PyTuple_New(elements);
#endif
}

inline ePyObject Impl_PyList_New(int elements=0)
{
#if PY_VERSION_HEX >= 0x030a0000
return PyList_New((Py_ssize_t)elements);
#else
return PyList_New(elements);
#endif
}

inline ePyObject Impl_PyDict_New()
Expand Down Expand Up @@ -377,20 +351,12 @@ inline ePyObject Impl_PyLong_FromUnsignedLongLong(unsigned long long val)

inline ePyObject Impl_PyList_GET_ITEM(ePyObject list, unsigned int pos)
{
#if PY_VERSION_HEX >= 0x030a0000
return PyList_GET_ITEM(list, (Py_ssize_t)pos);
#else
return PyList_GET_ITEM(list, pos);
#endif
}

inline ePyObject Impl_PyTuple_GET_ITEM(ePyObject list, unsigned int pos)
{
#if PY_VERSION_HEX >= 0x030a0000
return PyTuple_GET_ITEM(list, (Py_ssize_t)pos);
#else
return PyTuple_GET_ITEM(list, pos);
#endif
}
#endif

Expand Down
11 changes: 0 additions & 11 deletions lib/python/python_console.i
Expand Up @@ -188,24 +188,13 @@ eConsolePy_write(eConsolePy* self, PyObject *args)
{
char *data;
int len = -1;

#if PY_VERSION_HEX >= 0x030a0000
if (!PyArg_ParseTuple(args, "s|i", &data, &len))
{
PyErr_SetString(PyExc_TypeError,
"1st arg must be a string, optionaly 2nd arg can be the string length");
return NULL;
}
int data_len = strlen(data);
#else
int data_len;
if (!PyArg_ParseTuple(args, "s#|i", &data, &data_len, &len))
{
PyErr_SetString(PyExc_TypeError,
"1st arg must be a string, optionaly 2nd arg can be the string length");
return NULL;
}
#endif
if (len < 0)
len = data_len;
self->cont->write(data, len);
Expand Down

0 comments on commit 98a9b41

Please sign in to comment.