fix for Py_NotImplemented as reported by Olly and Amaury
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8862 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e66f81f904
commit
52106b3c6e
1 changed files with 24 additions and 10 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
/* Add PyOS_snprintf for old Pythons */
|
/* Add PyOS_snprintf for old Pythons */
|
||||||
#if PY_VERSION_HEX < 0x02020000
|
#if PY_VERSION_HEX < 0x02020000
|
||||||
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||||
# define PyOS_snprintf _snprintf
|
# define PyOS_snprintf _snprintf
|
||||||
# else
|
# else
|
||||||
# define PyOS_snprintf snprintf
|
# define PyOS_snprintf snprintf
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#if PY_VERSION_HEX < 0x02020000
|
#if PY_VERSION_HEX < 0x02020000
|
||||||
|
|
||||||
#ifndef SWIG_PYBUFFER_SIZE
|
#ifndef SWIG_PYBUFFER_SIZE
|
||||||
#define SWIG_PYBUFFER_SIZE 1024
|
# define SWIG_PYBUFFER_SIZE 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
@ -25,32 +25,46 @@ PyString_FromFormat(const char *fmt, ...) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
res = vsnprintf(buf, sizeof(buf), fmt, ap);
|
res = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf);
|
return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add PyObject_Del for old Pythons */
|
/* Add PyObject_Del for old Pythons */
|
||||||
#if PY_VERSION_HEX < 0x01060000
|
#if PY_VERSION_HEX < 0x01060000
|
||||||
#define PyObject_Del(op) PyMem_DEL((op))
|
# define PyObject_Del(op) PyMem_DEL((op))
|
||||||
#endif
|
#endif
|
||||||
#ifndef PyObject_DEL
|
#ifndef PyObject_DEL
|
||||||
#define PyObject_DEL PyObject_Del
|
# define PyObject_DEL PyObject_Del
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* A crude PyExc_StopIteration exception for old Pythons */
|
/* A crude PyExc_StopIteration exception for old Pythons */
|
||||||
#if PY_VERSION_HEX < 0x02020000
|
#if PY_VERSION_HEX < 0x02020000
|
||||||
#define PyExc_StopIteration PyExc_RuntimeError
|
# ifndef PyExc_StopIteration
|
||||||
#define PyObject_GenericGetAttr 0
|
# define PyExc_StopIteration PyExc_RuntimeError
|
||||||
#define Py_NotImplemented PyExc_RuntimeError
|
# endif
|
||||||
|
# ifndef PyObject_GenericGetAttr
|
||||||
|
# define PyObject_GenericGetAttr 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
/* Py_NotImplemented is defined in 2.1 and up. */
|
||||||
|
#if PY_VERSION_HEX < 0x02010000
|
||||||
|
# ifndef Py_NotImplemented
|
||||||
|
# define Py_NotImplemented PyExc_RuntimeError
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* A crude PyString_AsStringAndSize implementation for old Pythons */
|
/* A crude PyString_AsStringAndSize implementation for old Pythons */
|
||||||
#if PY_VERSION_HEX < 0x02010000
|
#if PY_VERSION_HEX < 0x02010000
|
||||||
#define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
|
# ifndef PyString_AsStringAndSize
|
||||||
|
# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* PySequence_Size for old Pythons */
|
||||||
#if PY_VERSION_HEX < 0x02000000
|
#if PY_VERSION_HEX < 0x02000000
|
||||||
#define PySequence_Size PySequence_Length
|
# ifndef PySequence_Size
|
||||||
|
# define PySequence_Size PySequence_Length
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue