summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/ctypes/__init__.py3
-rw-r--r--Lib/ctypes/_endian.py3
-rw-r--r--Lib/ctypes/macholib/__init__.py3
-rw-r--r--Lib/ctypes/macholib/dyld.py3
-rw-r--r--Lib/ctypes/macholib/dylib.py3
-rw-r--r--Lib/ctypes/macholib/framework.py3
-rw-r--r--Lib/ctypes/util.py3
-rw-r--r--Lib/ctypes/wintypes.py4
-rw-r--r--Modules/_ctypes/_ctypes.c89
-rw-r--r--Modules/_ctypes/_ctypes_test.c13
-rw-r--r--Modules/_ctypes/callbacks.c5
-rw-r--r--Modules/_ctypes/callproc.c13
-rw-r--r--Modules/_ctypes/cfield.c20
-rw-r--r--Modules/_ctypes/malloc_closure.c4
-rw-r--r--Modules/_ctypes/stgdict.c8
15 files changed, 0 insertions, 177 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 86678ea..f62c345 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -1,6 +1,3 @@
-######################################################################
-# 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
diff --git a/Lib/ctypes/_endian.py b/Lib/ctypes/_endian.py
index 138b248..b48bda5 100644
--- a/Lib/ctypes/_endian.py
+++ b/Lib/ctypes/_endian.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
import sys
from ctypes import *
diff --git a/Lib/ctypes/macholib/__init__.py b/Lib/ctypes/macholib/__init__.py
index 36149d2..5621def 100644
--- a/Lib/ctypes/macholib/__init__.py
+++ b/Lib/ctypes/macholib/__init__.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Enough Mach-O to make your head spin.
diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py
index c5a41de..837da4d 100644
--- a/Lib/ctypes/macholib/dyld.py
+++ b/Lib/ctypes/macholib/dyld.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
dyld emulation
"""
diff --git a/Lib/ctypes/macholib/dylib.py b/Lib/ctypes/macholib/dylib.py
index ea3dd38..aa10750 100644
--- a/Lib/ctypes/macholib/dylib.py
+++ b/Lib/ctypes/macholib/dylib.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic dylib path manipulation
"""
diff --git a/Lib/ctypes/macholib/framework.py b/Lib/ctypes/macholib/framework.py
index dd7fb2f..ad6ed55 100644
--- a/Lib/ctypes/macholib/framework.py
+++ b/Lib/ctypes/macholib/framework.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic framework path manipulation
"""
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 8a9b706..2aebc07 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -1,6 +1,3 @@
-######################################################################
-# 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.
diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py
index e97b31d..fdd08a0 100644
--- a/Lib/ctypes/wintypes.py
+++ b/Lib/ctypes/wintypes.py
@@ -1,7 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
-
# The most useful windows datatypes
from ctypes import *
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 5b11480..35f087d 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1,8 +1,3 @@
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
-
/*
ToDo:
@@ -365,11 +360,7 @@ CDataType_repeat(PyObject *self, Py_ssize_t length)
{
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);
}
@@ -1112,9 +1103,6 @@ static PyObject *
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;
@@ -1176,9 +1164,6 @@ static PyObject *
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;
@@ -1241,9 +1226,6 @@ c_void_p_from_param(PyObject *type, PyObject *value)
{
StgDictObject *stgd;
PyObject *as_parameter;
-#if (PYTHON_API_VERSION < 1012)
-# error not supported
-#endif
/* None */
if (value == Py_None) {
@@ -1388,20 +1370,11 @@ c_void_p_from_param(PyObject *type, PyObject *value)
"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)
{
@@ -1608,27 +1581,11 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
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);
@@ -1810,11 +1767,7 @@ converters_from_argtypes(PyObject *ob)
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;
}
@@ -2017,11 +1970,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
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 */
@@ -2030,11 +1979,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
"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);
@@ -3237,11 +3182,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
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;
}
@@ -3967,11 +3908,7 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
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);
@@ -4093,32 +4030,6 @@ static PyNumberMethods Simple_as_number = {
(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)
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index 8a198a7..39d9232 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -1,18 +1,5 @@
-/*****************************************************************
- 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
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 497599b..82f6cc1 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -1,9 +1,4 @@
-/*****************************************************************
- 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>
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 6380b1a..35453d5 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1,8 +1,3 @@
-/*****************************************************************
- 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.
@@ -1525,11 +1520,7 @@ resize(PyObject *self, PyObject *args)
Py_ssize_t size;
if (!PyArg_ParseTuple(args,
-#if (PY_VERSION_HEX < 0x02050000)
- "Oi:resize",
-#else
"On:resize",
-#endif
&obj, &size))
return NULL;
@@ -1541,11 +1532,7 @@ resize(PyObject *self, PyObject *args)
}
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;
}
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 8a0dfe7..da7e0fc 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1,7 +1,3 @@
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include "Python.h"
#include <ffi.h>
@@ -268,19 +264,11 @@ CField_repr(CFieldObject *self)
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;
}
@@ -1276,11 +1264,7 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
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;
@@ -1349,11 +1333,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length)
++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;
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index 4cd5dd6..29e9f4c 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -1,7 +1,3 @@
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include <Python.h>
#include <ffi.h>
#ifdef MS_WIN32
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index c35a515..b4a6e87 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -1,7 +1,3 @@
-/*****************************************************************
- This file should be kept compatible with Python 2.3, see PEP 291.
- *****************************************************************/
-
#include "Python.h"
#include <ffi.h>
#ifdef MS_WIN32
@@ -402,11 +398,7 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
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;
}