Skip to content

Commit 49b930a

Browse files
author
e1000
committed
C : PY_VERSION_HEX cleanup step 1
1 parent 71082fb commit 49b930a

File tree

4 files changed

+0
-92
lines changed

4 files changed

+0
-92
lines changed

src_c/_freetype.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,7 @@ PyTypeObject pgFont_Type = {
658658
0, /* tp_subclasses */
659659
0, /* tp_weaklist */
660660
0, /* tp_del */
661-
#if PY_VERSION_HEX >= 0x02060000
662661
0 /* tp_version_tag */
663-
#endif
664662
};
665663

666664
#undef FULL_TYPE_NAME

src_c/bufferproxy.c

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -79,73 +79,6 @@ proxy_releasebuffer(pgBufproxyObject *, Py_buffer *);
7979
static void
8080
_release_buffer_from_dict(Py_buffer *);
8181

82-
#if PY_VERSION_HEX < 0x02060000
83-
static int
84-
_IsFortranContiguous(Py_buffer *view)
85-
{
86-
Py_ssize_t sd, dim;
87-
int i;
88-
89-
if (view->ndim == 0)
90-
return 1;
91-
if (view->strides == NULL)
92-
return (view->ndim == 1);
93-
94-
sd = view->itemsize;
95-
if (view->ndim == 1)
96-
return (view->shape[0] == 1 || sd == view->strides[0]);
97-
for (i = 0; i < view->ndim; i++) {
98-
dim = view->shape[i];
99-
if (dim == 0)
100-
return 1;
101-
if (view->strides[i] != sd)
102-
return 0;
103-
sd *= dim;
104-
}
105-
return 1;
106-
}
107-
108-
static int
109-
_IsCContiguous(Py_buffer *view)
110-
{
111-
Py_ssize_t sd, dim;
112-
int i;
113-
114-
if (view->ndim == 0)
115-
return 1;
116-
if (view->strides == NULL)
117-
return 1;
118-
119-
sd = view->itemsize;
120-
if (view->ndim == 1)
121-
return (view->shape[0] == 1 || sd == view->strides[0]);
122-
for (i = view->ndim - 1; i >= 0; i--) {
123-
dim = view->shape[i];
124-
if (dim == 0)
125-
return 1;
126-
if (view->strides[i] != sd)
127-
return 0;
128-
sd *= dim;
129-
}
130-
return 1;
131-
}
132-
133-
static int
134-
PyBuffer_IsContiguous(Py_buffer *view, char fort)
135-
{
136-
if (view->suboffsets != NULL)
137-
return 0;
138-
139-
if (fort == 'C')
140-
return _IsCContiguous(view);
141-
else if (fort == 'F')
142-
return _IsFortranContiguous(view);
143-
else if (fort == 'A')
144-
return (_IsCContiguous(view) || _IsFortranContiguous(view));
145-
return 0;
146-
}
147-
#endif /* #if PY_VERSION_HEX < 0x02060000 */
148-
14982
static int
15083
_get_buffer_from_dict(PyObject *dict, Py_buffer *view_p, int flags)
15184
{
@@ -474,12 +407,7 @@ proxy_repr(pgBufproxyObject *self)
474407
if (!view_p) {
475408
return 0;
476409
}
477-
/* zd is for Py_size_t which python < 2.5 doesn't have. */
478-
#if PY_VERSION_HEX < 0x02050000
479-
return PyString_FromFormat("<BufferProxy(%d)>", view_p->len);
480-
#else
481410
return Text_FromFormat("<BufferProxy(%zd)>", view_p->len);
482-
#endif
483411
}
484412

485413
/**
@@ -494,11 +422,7 @@ proxy_write(pgBufproxyObject *self, PyObject *args, PyObject *kwds)
494422
Py_ssize_t offset = 0;
495423
char *keywords[] = {"buffer", "offset", 0};
496424

497-
#if Py_VERSION_HEX >= 0x02050000
498425
#define ARG_FORMAT "s#|n"
499-
#else
500-
#define ARG_FORMAT "s#|i" /* In this case Py_ssize_t is an int */
501-
#endif
502426
if (!PyArg_ParseTupleAndKeywords(args, kwds, ARG_FORMAT, keywords, &buf,
503427
&buflen, &offset)) {
504428
return 0;

src_c/newbuffer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,7 @@ static PyNumberMethods buffer_as_number = {
731731
(binaryfunc)0, /* nb_true_divide */
732732
(binaryfunc)0, /* nb_inplace_floor_divide */
733733
(binaryfunc)0, /* nb_inplace_true_divide */
734-
#if PY_VERSION_HEX >= 0x02050000
735734
(unaryfunc)0, /* nb_index */
736-
#endif
737735
};
738736

739737
#define BUFFER_TYPE_FULLNAME "newbuffer.Py_buffer"

src_c/pixelarray.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828

2929
#include "surface.h"
3030

31-
#if PY_VERSION_HEX < 0x02050000
32-
#define PyIndex_Check(op) 0
33-
#endif
34-
3531
static char FormatUint8[] = "B";
3632
static char FormatUint16[] = "=H";
3733
static char FormatUint24[] = "3x";
@@ -1733,17 +1729,13 @@ _pxarray_subscript(pgPixelArrayObject *array, PyObject *op)
17331729
}
17341730
else if (PyIndex_Check(op) || PyInt_Check(op) || PyLong_Check(op)) {
17351731
Py_ssize_t i;
1736-
#if PY_VERSION_HEX >= 0x02050000
17371732
PyObject *val = PyNumber_Index(op);
17381733
if (!val) {
17391734
return 0;
17401735
}
17411736
/* A simple index. */
17421737
i = PyNumber_AsSsize_t(val, PyExc_IndexError);
17431738
Py_DECREF(val);
1744-
#else
1745-
i = PyInt_Check(op) ? PyInt_AsLong(op) : PyLong_AsLong(op);
1746-
#endif
17471739
if (i == -1 && PyErr_Occurred()) {
17481740
return 0;
17491741
}
@@ -1899,17 +1891,13 @@ _pxarray_ass_subscript(pgPixelArrayObject *array, PyObject *op,
18991891
}
19001892
else if (PyIndex_Check(op) || PyInt_Check(op) || PyLong_Check(op)) {
19011893
Py_ssize_t i;
1902-
#if PY_VERSION_HEX >= 0x02050000
19031894
PyObject *val = PyNumber_Index(op);
19041895
if (!val) {
19051896
return -1;
19061897
}
19071898
/* A simple index. */
19081899
i = PyNumber_AsSsize_t(val, PyExc_IndexError);
19091900
Py_DECREF(val);
1910-
#else
1911-
i = PyInt_Check(op) ? PyInt_AsLong(op) : PyLong_AsLong(op);
1912-
#endif
19131901
if (i == -1 && PyErr_Occurred()) {
19141902
return -1;
19151903
}

0 commit comments

Comments
 (0)