File: mmap-64bit.dpatch

package info (click to toggle)
python2.4 2.4.6-1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 44,888 kB
  • ctags: 86,995
  • sloc: ansic: 306,391; python: 271,931; sh: 10,210; makefile: 4,248; perl: 3,736; lisp: 3,678; xml: 894; objc: 756; cpp: 7; sed: 2
file content (143 lines) | stat: -rw-r--r-- 3,900 bytes parent folder | download | duplicates (3)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#! /bin/sh -e

# DP: Patch #1365916: fix some unsafe 64-bit mmap methods, backport from 2.5

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        ;;
    *)
	echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
        exit 1
esac
exit 0

--- Lib/test/test_mmap.py.orig	2006-03-23 20:07:46.000000000 +0100
+++ Lib/test/test_mmap.py	2007-01-12 02:11:27.000000000 +0100
@@ -328,6 +328,22 @@
         os.unlink(TESTFN)
 
 
+    # make move works everywhere (64-bit format problem earlier)
+    f = open(TESTFN, 'w+')
+
+    try:    # unlink TESTFN no matter what
+        f.write("ABCDEabcde") # Arbitrary character
+        f.flush()
+
+        mf = mmap.mmap(f.fileno(), 10)
+        mf.move(5, 0, 5)
+        verify(mf[:] == "ABCDEABCDE", "Map move should have duplicated front 5")
+        mf.close()
+        f.close()
+
+    finally:
+        os.unlink(TESTFN)
+
     print ' Test passed'
 
 test_both()
--- Modules/mmapmodule.c.orig	2006-09-27 21:17:32.000000000 +0200
+++ Modules/mmapmodule.c	2007-01-12 02:12:31.000000000 +0100
@@ -374,7 +374,7 @@
 {
 	unsigned long new_size;
 	CHECK_VALID(NULL);
-	if (!PyArg_ParseTuple (args, "l:resize", &new_size) || 
+	if (!PyArg_ParseTuple (args, "k:resize", &new_size) || 
 	    !is_resizeable(self)) {
 		return NULL;
 #ifdef MS_WINDOWS
@@ -463,10 +463,10 @@
 static PyObject *
 mmap_flush_method(mmap_object *self, PyObject *args)
 {
-	size_t offset	= 0;
-	size_t size = self->size;
+	unsigned long offset = 0;
+	unsigned long size = self->size;
 	CHECK_VALID(NULL);
-	if (!PyArg_ParseTuple (args, "|ll:flush", &offset, &size)) {
+	if (!PyArg_ParseTuple (args, "|kk:flush", &offset, &size)) {
 		return NULL;
 	} else if ((offset + size) > self->size) {
 		PyErr_SetString (PyExc_ValueError,
@@ -539,7 +539,7 @@
 {
 	unsigned long dest, src, count;
 	CHECK_VALID(NULL);
-	if (!PyArg_ParseTuple (args, "iii:move", &dest, &src, &count) ||
+	if (!PyArg_ParseTuple (args, "kkk:move", &dest, &src, &count) ||
 	    !is_writeable(self)) {
 		return NULL;
 	} else {
@@ -863,7 +863,7 @@
 	PyObject *map_size_obj = NULL;
 	int map_size;
 	int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ;
-	access_mode access = ACCESS_DEFAULT;
+	int access = (int)ACCESS_DEFAULT;
 	char *keywords[] = {"fileno", "length", 
 			    "flags", "prot", 
 			    "access", NULL};
@@ -875,11 +875,11 @@
 	if (map_size < 0)
 		return NULL;
 
-	if ((access != ACCESS_DEFAULT) && 
+	if ((access != (int)ACCESS_DEFAULT) && 
 	    ((flags != MAP_SHARED) || ( prot != (PROT_WRITE | PROT_READ))))
 		return PyErr_Format(PyExc_ValueError, 
 				    "mmap can't specify both access and flags, prot.");
-	switch(access) {
+	switch((access_mode)access) {
 	case ACCESS_READ:
 		flags = MAP_SHARED;
 		prot = PROT_READ;
@@ -937,7 +937,7 @@
 		PyErr_SetFromErrno(mmap_module_error);
 		return NULL;
 	}
-	m_obj->access = access;
+	m_obj->access = (access_mode)access;
 	return (PyObject *)m_obj;
 }
 #endif /* UNIX */
@@ -953,7 +953,7 @@
 	DWORD dwErr = 0;
 	int fileno;
 	HANDLE fh = 0;
-	access_mode   access = ACCESS_DEFAULT;
+	int access = (access_mode)ACCESS_DEFAULT;
 	DWORD flProtect, dwDesiredAccess;
 	char *keywords[] = { "fileno", "length", 
 			     "tagname", 
@@ -965,7 +965,7 @@
 		return NULL;
 	}
 
-	switch(access) {
+	switch((access_mode)access) {
 	case ACCESS_READ:
 		flProtect = PAGE_READONLY;
 		dwDesiredAccess = FILE_MAP_READ;
@@ -1050,7 +1050,7 @@
 	else
 		m_obj->tagname = NULL;
 
-	m_obj->access = access;
+	m_obj->access = (access_mode)access;
 	m_obj->map_handle = CreateFileMapping (m_obj->file_handle,
 					       NULL,
 					       flProtect,