1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
$NetBSD: patch-aa,v 1.4 2012/02/05 22:27:09 sbd Exp $
Fix for LP64 on python > 2.4.
--- pyid3lib.cc.orig 2003-02-16 23:50:20.000000000 +0000
+++ pyid3lib.cc
@@ -10,6 +10,17 @@
#include <id3/id3lib_frame.h>
#include <id3/tag.h>
+#if defined(PY_MAJOR_VERSION) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
+typedef int Py_ssize_t;
+typedef intargfunc ssizeargfunc;
+typedef intintargfunc ssizessizeargfunc;
+typedef intobjargproc ssizeobjargproc;
+typedef intintobjargproc ssizessizeobjargproc;
+#define LENFUNC inquiry
+#else
+#define LENFUNC lenfunc
+#endif
+
typedef struct
{
PyObject_HEAD
@@ -61,11 +72,11 @@ static PyObject* dict_from_frame( ID3_Fr
static ID3_Frame* frame_from_dict( PyObject* dict );
static ID3_Frame* frame_from_dict( ID3_FrameID fid, PyObject* dict );
-static int id3_length( ID3Object* self );
-static PyObject* id3_item( ID3Object* self, int index );
-static PyObject* id3_slice( ID3Object* self, int start, int end );
-static int id3_ass_item( ID3Object* self, int index, PyObject* dict );
-static int id3_ass_slice( ID3Object* self, int start, int end, PyObject* dict );
+static Py_ssize_t id3_length( ID3Object* self );
+static PyObject* id3_item( ID3Object* self, Py_ssize_t index );
+static PyObject* id3_slice( ID3Object* self, Py_ssize_t start, Py_ssize_t end );
+static int id3_ass_item( ID3Object* self, Py_ssize_t index, PyObject* dict );
+static int id3_ass_slice( ID3Object* self, Py_ssize_t start, Py_ssize_t end, PyObject* dict );
static int id3_contains( ID3Object* self, PyObject* other );
static PyObject* id3_append( ID3Object* self, PyObject* args );
@@ -80,13 +91,13 @@ static PyObject* frameid_lookup = NULL;
static PySequenceMethods tag_as_sequence = {
- (inquiry)id3_length,
+ (LENFUNC)id3_length,
NULL,
NULL,
- (intargfunc)id3_item,
- (intintargfunc)id3_slice,
- (intobjargproc)id3_ass_item,
- (intintobjargproc)id3_ass_slice,
+ (ssizeargfunc)id3_item,
+ (ssizessizeargfunc)id3_slice,
+ (ssizeobjargproc)id3_ass_item,
+ (ssizessizeobjargproc)id3_ass_slice,
(objobjproc)id3_contains,
NULL,
NULL,
@@ -236,12 +247,12 @@ static PyObject* id3iter_iternext( ID3It
//
/////////////////
-static int id3_length( ID3Object* self )
+static Py_ssize_t id3_length( ID3Object* self )
{
return self->size;
}
-static PyObject* id3_item( ID3Object* self, int index )
+static PyObject* id3_item( ID3Object* self, Py_ssize_t index )
{
if ( index < 0 )
index += self->size;
@@ -255,7 +266,7 @@ static PyObject* id3_item( ID3Object* se
return dict_from_frame( self->frames[index] );
}
-static PyObject* id3_slice( ID3Object* self, int start, int end )
+static PyObject* id3_slice( ID3Object* self, Py_ssize_t start, Py_ssize_t end )
{
PyObject* result;
int i;
@@ -284,7 +295,7 @@ static PyObject* id3_slice( ID3Object* s
}
-static int id3_ass_item( ID3Object* self, int index, PyObject* dict )
+static int id3_ass_item( ID3Object* self, Py_ssize_t index, PyObject* dict )
{
ID3_Frame* newframe;
@@ -382,7 +393,7 @@ static ID3_Frame** frames_from_dictseq(
return NULL;
}
-static int id3_ass_slice( ID3Object* self, int start, int end, PyObject* dictseq )
+static int id3_ass_slice( ID3Object* self, Py_ssize_t start, Py_ssize_t end, PyObject* dictseq )
{
int i, n;
int newsize;
@@ -824,7 +835,7 @@ static ID3_Frame* frame_from_dict( PyObj
static ID3_Frame* frame_from_dict( ID3_FrameID fid, PyObject* dict )
{
char* data;
- int size;
+ Py_ssize_t size;
ID3_Field* field;
ID3_FieldID flid;
@@ -1054,7 +1065,7 @@ static PyObject* id3_getattr( ID3Object*
fld = frame->GetField( ID3FN_TEXT );
str = fld->GetRawText();
- if ( (slash = strchr( str, '/' )) != NULL )
+ if ( (slash = (char *)strchr( str, '/' )) != NULL )
result = Py_BuildValue( "ii", atoi( str ), atoi( slash+1 ) );
else
result = Py_BuildValue( "(i)", atoi( str ) );
|