version is not compatible with Python 2.x anymore).
Remove backwards compatibility code.
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""create and manipulate C data types in Python"""
import os as _os, sys as _sys
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
import sys
from ctypes import *
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Enough Mach-O to make your head spin.
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
dyld emulation
"""
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic dylib path manipulation
"""
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic framework path manipulation
"""
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
import sys, os
# find_library(name) returns the pathname of a library, or None.
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
-
# The most useful windows datatypes
from ctypes import *
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
-
/*
ToDo:
{
if (length < 0)
return PyErr_Format(PyExc_ValueError,
-#if (PY_VERSION_HEX < 0x02050000)
- "Array length must be >= 0, not %d",
-#else
"Array length must be >= 0, not %zd",
-#endif
length);
return CreateArrayType(self, length);
}
c_wchar_p_from_param(PyObject *type, PyObject *value)
{
PyObject *as_parameter;
-#if (PYTHON_API_VERSION < 1012)
-# error not supported
-#endif
if (value == Py_None) {
Py_INCREF(Py_None);
return Py_None;
c_char_p_from_param(PyObject *type, PyObject *value)
{
PyObject *as_parameter;
-#if (PYTHON_API_VERSION < 1012)
-# error not supported
-#endif
if (value == Py_None) {
Py_INCREF(Py_None);
return Py_None;
{
StgDictObject *stgd;
PyObject *as_parameter;
-#if (PYTHON_API_VERSION < 1012)
-# error not supported
-#endif
/* None */
if (value == Py_None) {
"wrong type");
return NULL;
}
-#if (PYTHON_API_VERSION >= 1012)
static PyMethodDef c_void_p_method = { "from_param", c_void_p_from_param, METH_O };
static PyMethodDef c_char_p_method = { "from_param", c_char_p_from_param, METH_O };
static PyMethodDef c_wchar_p_method = { "from_param", c_wchar_p_from_param, METH_O };
-#else
-#error
-static PyMethodDef c_void_p_method = { "from_param", c_void_p_from_param, METH_VARARGS };
-static PyMethodDef c_char_p_method = { "from_param", c_char_p_from_param, METH_VARARGS };
-static PyMethodDef c_wchar_p_method = { "from_param", c_wchar_p_from_param, METH_VARARGS };
-
-#endif
-
static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject *kwds,
PyObject *proto, struct fielddesc *fmt)
{
}
if (ml) {
-#if (PYTHON_API_VERSION >= 1012)
PyObject *meth;
int x;
meth = PyDescr_NewClassMethod(result, ml);
if (!meth)
return NULL;
-#else
-#error
- PyObject *meth, *func;
- int x;
- func = PyCFunction_New(ml, NULL);
- if (!func)
- return NULL;
- meth = PyObject_CallFunctionObjArgs(
- (PyObject *)&PyClassMethod_Type,
- func, NULL);
- Py_DECREF(func);
- if (!meth) {
- return NULL;
- }
-#endif
x = PyDict_SetItemString(result->tp_dict,
ml->ml_name,
meth);
Py_XDECREF(converters);
Py_DECREF(ob);
PyErr_Format(PyExc_TypeError,
-#if (PY_VERSION_HEX < 0x02050000)
- "item %d in _argtypes_ has no from_param method",
-#else
"item %zd in _argtypes_ has no from_param method",
-#endif
i+1);
return NULL;
}
size_t bytes_left;
assert(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
-#if (PY_VERSION_HEX < 0x02050000)
- cp += sprintf(cp, "%x", index);
-#else
cp += sprintf(cp, "%x", Py_SAFE_DOWNCAST(index, Py_ssize_t, int));
-#endif
while (target->b_base) {
bytes_left = sizeof(string) - (cp - string) - 1;
/* Hex format needs 2 characters per byte */
"ctypes object structure too deep");
return NULL;
}
-#if (PY_VERSION_HEX < 0x02050000)
- cp += sprintf(cp, ":%x", (int)target->b_index);
-#else
cp += sprintf(cp, ":%x", Py_SAFE_DOWNCAST(target->b_index, Py_ssize_t, int));
-#endif
target = target->b_base;
}
return PyUnicode_FromStringAndSize(string, cp-string);
message is misleading. See unittests/test_paramflags.py
*/
PyErr_Format(PyExc_TypeError,
-#if (PY_VERSION_HEX < 0x02050000)
- "call takes exactly %d arguments (%d given)",
-#else
"call takes exactly %d arguments (%zd given)",
-#endif
inargs_index, actual_args);
goto error;
}
if (cache == NULL)
return NULL;
}
-#if (PY_VERSION_HEX < 0x02050000)
- key = Py_BuildValue("(Oi)", itemtype, length);
-#else
key = Py_BuildValue("(On)", itemtype, length);
-#endif
if (!key)
return NULL;
result = PyDict_GetItem(cache, key);
(inquiry)Simple_bool, /* nb_bool */
};
-#if (PY_VERSION_HEX < 0x02040000)
-/* Only in Python 2.4 and up */
-static PyObject *
-PyTuple_Pack(int n, ...)
-{
- int i;
- PyObject *o;
- PyObject *result;
- PyObject **items;
- va_list vargs;
-
- va_start(vargs, n);
- result = PyTuple_New(n);
- if (result == NULL)
- return NULL;
- items = ((PyTupleObject *)result)->ob_item;
- for (i = 0; i < n; i++) {
- o = va_arg(vargs, PyObject *);
- Py_INCREF(o);
- items[i] = o;
- }
- va_end(vargs);
- return result;
-}
-#endif
-
/* "%s(%s)" % (self.__class__.__name__, self.value) */
static PyObject *
Simple_repr(CDataObject *self)
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
-
#include <Python.h>
-/*
- Backwards compatibility:
- Python2.2 used LONG_LONG instead of PY_LONG_LONG
-*/
-#if defined(HAVE_LONG_LONG) && !defined(PY_LONG_LONG)
-#define PY_LONG_LONG LONG_LONG
-#endif
-
#ifdef MS_WIN32
#include <windows.h>
#endif
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include "Python.h"
-#include "compile.h" /* required only for 2.3, as it seems */
#include "frameobject.h"
#include <ffi.h>
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
-
/*
* History: First version dated from 3/97, derived from my SCMLIB version
* for win16.
Py_ssize_t size;
if (!PyArg_ParseTuple(args,
-#if (PY_VERSION_HEX < 0x02050000)
- "Oi:resize",
-#else
"On:resize",
-#endif
&obj, &size))
return NULL;
}
if (size < dict->size) {
PyErr_Format(PyExc_ValueError,
-#if PY_VERSION_HEX < 0x02050000
- "minimum size is %d",
-#else
"minimum size is %zd",
-#endif
dict->size);
return NULL;
}
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include "Python.h"
#include <ffi.h>
if (bits)
result = PyUnicode_FromFormat(
-#if (PY_VERSION_HEX < 0x02050000)
- "<Field type=%s, ofs=%d:%d, bits=%d>",
-#else
"<Field type=%s, ofs=%zd:%zd, bits=%zd>",
-#endif
name, self->offset, size, bits);
else
result = PyUnicode_FromFormat(
-#if (PY_VERSION_HEX < 0x02050000)
- "<Field type=%s, ofs=%d, size=%d>",
-#else
"<Field type=%s, ofs=%zd, size=%zd>",
-#endif
name, self->offset, size);
return result;
}
size = PyUnicode_GET_SIZE(value);
if (size > length) {
PyErr_Format(PyExc_ValueError,
-#if (PY_VERSION_HEX < 0x02050000)
- "string too long (%d, maximum length %d)",
-#else
"string too long (%zd, maximum length %zd)",
-#endif
size, length);
Py_DECREF(value);
return NULL;
++size;
} else if (size > length) {
PyErr_Format(PyExc_ValueError,
-#if (PY_VERSION_HEX < 0x02050000)
- "string too long (%d, maximum length %d)",
-#else
"string too long (%zd, maximum length %zd)",
-#endif
size, length);
Py_DECREF(value);
return NULL;
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include <Python.h>
#include <ffi.h>
#ifdef MS_WIN32
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include "Python.h"
#include <ffi.h>
#ifdef MS_WIN32
if (dict == NULL) {
Py_DECREF(pair);
PyErr_Format(PyExc_TypeError,
-#if (PY_VERSION_HEX < 0x02050000)
- "second item in _fields_ tuple (index %d) must be a C type",
-#else
"second item in _fields_ tuple (index %zd) must be a C type",
-#endif
i);
return -1;
}