Armed with a text editor

mu's views on program and recipe! design

Index: Lib/test/test_mmap.py
===================================================================
--- Lib/test/test_mmap.py	(revision 41738)
+++ Lib/test/test_mmap.py	(working copy)
@@ -356,6 +356,22 @@
         finally:
             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()
Index: Modules/socketmodule.c
===================================================================
--- Modules/socketmodule.c	(revision 41738)
+++ Modules/socketmodule.c	(working copy)
@@ -1154,14 +1154,16 @@
 		{
 			struct sockaddr_l2 *addr = (struct sockaddr_l2 *) _BT_SOCKADDR_MEMB(s, l2);
 			char *straddr;
+			int parse_psm;
 
 			_BT_L2_MEMB(addr, family) = AF_BLUETOOTH;
 			if (!PyArg_ParseTuple(args, "si", &straddr,
-					      &_BT_L2_MEMB(addr, psm))) {
+					      &parse_psm)) {
 				PyErr_SetString(socket_error, "getsockaddrarg: "
 						"wrong format");
 				return 0;
 			}
+		        _BT_L2_MEMB(addr, psm) = parse_psm;
 			if (setbdaddr(straddr, &_BT_L2_MEMB(addr, bdaddr)) < 0)
 				return 0;
 
@@ -1173,14 +1175,16 @@
 		{
 			struct sockaddr_rc *addr = (struct sockaddr_rc *) _BT_SOCKADDR_MEMB(s, rc);
 			char *straddr;
+			int parse_channel;
 
 			_BT_RC_MEMB(addr, family) = AF_BLUETOOTH;
 			if (!PyArg_ParseTuple(args, "si", &straddr,
-					      &_BT_RC_MEMB(addr, channel))) {
+					      &parse_channel)) {
 				PyErr_SetString(socket_error, "getsockaddrarg: "
 						"wrong format");
 				return 0;
 			}
+			_BT_RC_MEMB(addr, channel) = parse_channel;
 			if (setbdaddr(straddr, &_BT_RC_MEMB(addr, bdaddr)) < 0)
 				return 0;
 
@@ -1226,7 +1230,7 @@
 		int hatype = 0;
 		int pkttype = 0;
 		char *haddr = NULL;
-		unsigned int halen = 0;
+		int halen = 0;
 
 		if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName,
 				      &protoNumber, &pkttype, &hatype,
@@ -1580,6 +1584,7 @@
 	int res;
 	PyObject *buf;
 	socklen_t buflen = 0;
+	int parse_buflen = buflen;
 
 #ifdef __BEOS__
 	/* We have incomplete socket support. */
@@ -1588,8 +1593,9 @@
 #else
 
 	if (!PyArg_ParseTuple(args, "ii|i:getsockopt",
-			      &level, &optname, &buflen))
+			      &level, &optname, &parse_buflen))
 		return NULL;
+        buflen = parse_buflen;
 
 	if (buflen == 0) {
 		int flag = 0;
@@ -3067,10 +3073,11 @@
 {
 	PySocketSockObject *s;
 	SOCKET_T fd;
-	int family, type, proto = 0;
+	int family, type, proto = 0, parse_fd;
 	if (!PyArg_ParseTuple(args, "iii|i:fromfd",
-			      &fd, &family, &type, &proto))
+			      &parse_fd, &family, &type, &proto))
 		return NULL;
+	fd = parse_fd;
 	/* Dup the fd so it and the socket can be closed independently */
 	fd = dup(fd);
 	if (fd < 0)
Index: Modules/mmapmodule.c
===================================================================
--- Modules/mmapmodule.c	(revision 41738)
+++ Modules/mmapmodule.c	(working copy)
@@ -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 {
@@ -864,14 +864,16 @@
 	int map_size;
 	int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ;
 	access_mode access = ACCESS_DEFAULT;
+	int parse_access = access;
 	static const char *keywords[] = {"fileno", "length", 
                                          "flags", "prot", 
                                          "access", NULL};
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords, 
 					 &fd, &map_size_obj, &flags, &prot,
-                                         &access))
+                                         &parse_access))
 		return NULL;
+	access = parse_access;
 	map_size = _GetMapSize(map_size_obj);
 	if (map_size < 0)
 		return NULL;
@@ -952,6 +954,7 @@
 	int fileno;
 	HANDLE fh = 0;
 	access_mode   access = ACCESS_DEFAULT;
+	int parse_access = access;
 	DWORD flProtect, dwDesiredAccess;
 	static const char *keywords[] = { "fileno", "length", 
                                           "tagname", 
@@ -959,9 +962,10 @@
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords,
 					 &fileno, &map_size_obj, 
-					 &tagname, &access)) {
+					 &tagname, &parse_access)) {
 		return NULL;
 	}
+	access = parse_access;
 
 	switch(access) {
 	case ACCESS_READ:
Index: Modules/xxmodule.c
===================================================================
--- Modules/xxmodule.c	(revision 41738)
+++ Modules/xxmodule.c	(working copy)
@@ -203,7 +203,7 @@
 xx_roj(PyObject *self, PyObject *args)
 {
 	PyObject *a;
-	long b;
+	int b;
 	if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
 		return NULL;
 	Py_INCREF(Py_None);
Index: Modules/_bsddb.c
===================================================================
--- Modules/_bsddb.c	(revision 41738)
+++ Modules/_bsddb.c	(working copy)
@@ -225,7 +225,7 @@
 typedef struct {
     PyObject_HEAD
     DB_ENV*     db_env;
-    u_int32_t   flags;             /* saved flags from open() */
+    int         flags;             /* saved flags from open() */
     int         closed;
     struct behaviourFlags moduleFlags;
 #ifdef HAVE_WEAKREF
@@ -238,8 +238,8 @@
     PyObject_HEAD
     DB*             db;
     DBEnvObject*    myenvobj;  /* PyObject containing the DB_ENV */
-    u_int32_t       flags;     /* saved flags from open() */
-    u_int32_t       setflags;  /* saved flags from set_flags() */
+    int             flags;     /* saved flags from open() */
+    int             setflags;  /* saved flags from set_flags() */
     int             haveStat;
     struct behaviourFlags moduleFlags;
 #if (DBVER >= 33)
@@ -2581,7 +2581,7 @@
 DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
 {
     int err;
-    u_int32_t flags=0;
+    int flags=0;
     char *passwd = NULL;
     static const char* kwnames[] = { "passwd", "flags", NULL };
 
@@ -3749,7 +3749,7 @@
 DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 {
     int err;
-    u_int32_t flags=0;
+    int flags=0;
     char *file = NULL;
     char *database = NULL;
     PyObject *txnobj = NULL;
@@ -3776,7 +3776,7 @@
 DBEnv_dbrename(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 {
     int err;
-    u_int32_t flags=0;
+    int flags=0;
     char *file = NULL;
     char *database = NULL;
     char *newname = NULL;
@@ -3805,7 +3805,7 @@
 DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 {
     int err;
-    u_int32_t flags=0;
+    int flags=0;
     char *passwd = NULL;
     static const char* kwnames[] = { "passwd", "flags", NULL };
 
@@ -3828,8 +3828,8 @@
 DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 {
     int err;
-    u_int32_t flags=0;
-    u_int32_t timeout = 0;
+    int flags=0;
+    int timeout = 0;
     static const char* kwnames[] = { "timeout", "flags", NULL };
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
@@ -4214,7 +4214,7 @@
 DBEnv_lock_id(DBEnvObject* self, PyObject* args)
 {
     int err;
-    u_int32_t theID;
+    int theID;
 
     if (!PyArg_ParseTuple(args, ":lock_id"))
         return NULL;
@@ -4261,7 +4261,7 @@
     int err;
     DB_LOCK_STAT* sp;
     PyObject* d = NULL;
-    u_int32_t flags = 0;
+    int flags = 0;
 
     if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags))
         return NULL;
@@ -4376,7 +4376,7 @@
     int err;
     DB_TXN_STAT* sp;
     PyObject* d = NULL;
-    u_int32_t flags=0;
+    int flags=0;
 
     if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
         return NULL;
Index: Modules/gdbmmodule.c
===================================================================
--- Modules/gdbmmodule.c	(revision 41738)
+++ Modules/gdbmmodule.c	(working copy)
@@ -253,9 +253,11 @@
 dbm_has_key(register dbmobject *dp, PyObject *args)
 {
     datum key;
+    int parse_key_dsize
 
-    if (!PyArg_ParseTuple(args, "s#:has_key", &key.dptr, &key.dsize))
+    if (!PyArg_ParseTuple(args, "s#:has_key", &key.dptr, &parse_key_dsize))
         return NULL;
+    key.dsize = parse_key_dsize;
     check_dbmobject_open(dp);
     return PyInt_FromLong((long) gdbm_exists(dp->di_dbm, key));
 }
@@ -304,9 +306,11 @@
 {
     register PyObject *v;
     datum key, nextkey;
+    int parse_key_dsize;
 
-    if (!PyArg_ParseTuple(args, "s#:nextkey", &key.dptr, &key.dsize))
+    if (!PyArg_ParseTuple(args, "s#:nextkey", &key.dptr, &parse_key_dsize))
         return NULL;
+    key.dsize = parse_key_dsize;
     check_dbmobject_open(dp);
     nextkey = gdbm_nextkey(dp->di_dbm, key);
     if (nextkey.dptr) {
Index: Modules/bsddbmodule.c
===================================================================
--- Modules/bsddbmodule.c	(revision 41738)
+++ Modules/bsddbmodule.c	(working copy)
@@ -468,12 +468,14 @@
 	char *data;
 	int size;
 	recno_t recno;
+        int parse_recno;
 
 	if (dp->di_type == DB_RECNO) {
 		if (!PyArg_ParseTuple(args, "i;key type must be integer",
-				      &recno)) {
+				      &parse_recno)) {
 			return NULL;
 		}
+		recno = parse_recno;
 		krec.data = &recno;
 		krec.size = sizeof(recno);
 	}
@@ -507,12 +509,14 @@
 	int size;
 	PyObject *result;
 	recno_t recno;
+	int parse_recno;
 
 	if (dp->di_type == DB_RECNO) {
 		if (!PyArg_ParseTuple(key, "i;key type must be integer",
-				      &recno)) {
+				      &parse_recno)) {
 			return NULL;
 		}
+		recno = parse_recno;
 		krec.data = &recno;
 		krec.size = sizeof(recno);
 	}
@@ -738,7 +742,7 @@
 	unsigned int psize = 0;
 	int lorder = 0;
 
-	if (!PyArg_ParseTuple(args, "z|siiiiiii:btopen",
+	if (!PyArg_ParseTuple(args, "z|siiiiiIi:btopen",
 			      &file, &flag, &mode,
 			      &btflags, &cachesize, &maxkeypage, &minkeypage,
 			      &psize, &lorder))
@@ -790,12 +794,14 @@
 	size_t reclen = 0;
 	char  *bval = "";
 	char *bfname = NULL;
+	unsigned long parse_reclen = reclen;
 
-	if (!PyArg_ParseTuple(args, "z|siiiiiiss:rnopen",
+	if (!PyArg_ParseTuple(args, "z|siiiIikss:rnopen",
 			      &file, &flag, &mode,
 			      &rnflags, &cachesize, &psize, &lorder,
-			      &reclen, &bval, &bfname))
+			      &parse_reclen, &bval, &bfname))
 		return NULL;
+	reclen = parse_reclen;
 
 	if (flag != NULL) {
 		/* XXX need to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */
Index: Modules/cdmodule.c
===================================================================
--- Modules/cdmodule.c	(revision 41738)
+++ Modules/cdmodule.c	(working copy)
@@ -297,7 +297,7 @@
 {
 	unsigned long PyTryBlock;
 
-	if (!PyArg_ParseTuple(args, "l:seekblock", &PyTryBlock))
+	if (!PyArg_ParseTuple(args, "k:seekblock", &PyTryBlock))
 		return NULL;
 
 	PyTryBlock = CDseekblock(self->ob_cdplayer, PyTryBlock);
Index: Modules/_cursesmodule.c
===================================================================
--- Modules/_cursesmodule.c	(revision 41738)
+++ Modules/_cursesmodule.c	(working copy)
@@ -369,6 +369,7 @@
   PyObject *temp;
   chtype ch = 0;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
   
   switch (PyTuple_Size(args)) {
   case 1:
@@ -376,7 +377,7 @@
 	  return NULL;
     break;
   case 2:
-    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
+    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &parse_attr))
       return NULL;
     break;
   case 3:
@@ -386,7 +387,7 @@
     break;
   case 4:
     if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", 
-		     &y, &x, &temp, &attr))
+		     &y, &x, &temp, &parse_attr))
       return NULL;
     use_xy = TRUE;
     break;
@@ -394,6 +395,7 @@
     PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (!PyCurses_ConvertToChtype(temp, &ch)) {
     PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
@@ -416,6 +418,7 @@
   char *str;
   attr_t attr = A_NORMAL , attr_old = A_NORMAL;
   int use_xy = FALSE, use_attr = FALSE;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 1:
@@ -423,7 +426,7 @@
       return NULL;
     break;
   case 2:
-    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
+    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &parse_attr))
       return NULL;
     use_attr = TRUE;
     break;
@@ -433,7 +436,8 @@
     use_xy = TRUE;
     break;
   case 4:
-    if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &attr))
+    if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str,
+                          &parse_attr))
       return NULL;
     use_xy = use_attr = TRUE;
     break;
@@ -441,6 +445,7 @@
     PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (use_attr == TRUE) {
     attr_old = getattrs(self->win);
@@ -462,6 +467,7 @@
   char *str;
   attr_t attr = A_NORMAL , attr_old = A_NORMAL;
   int use_xy = FALSE, use_attr = FALSE;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 2:
@@ -469,7 +475,7 @@
       return NULL;
     break;
   case 3:
-    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
+    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &parse_attr))
       return NULL;
     use_attr = TRUE;
     break;
@@ -479,7 +485,8 @@
     use_xy = TRUE;
     break;
   case 5:
-    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
+    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n,
+                          &parse_attr))
       return NULL;
     use_xy = use_attr = TRUE;
     break;
@@ -487,6 +494,7 @@
     PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (use_attr == TRUE) {
     attr_old = getattrs(self->win);
@@ -507,6 +515,7 @@
   PyObject *temp;
   chtype bkgd;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
     case 1:
@@ -514,13 +523,14 @@
         return NULL;
       break;
     case 2:
-      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &parse_attr))
         return NULL;
       break;
     default:
       PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
       return NULL;
   }
+  attr = parse_attr;
 
   if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
     PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
@@ -536,6 +546,7 @@
   PyObject *temp;
   chtype bkgd;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
     case 1:
@@ -543,13 +554,14 @@
         return NULL;
       break;
     case 2:
-      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &parse_attr))
         return NULL;
       break;
     default:
       PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
       return NULL;
   }
+  attr = parse_attr;
 
   if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
     PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
@@ -597,12 +609,15 @@
 PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args)
 {
   chtype ch1=0,ch2=0;
+  unsigned long parse_ch1=ch1, parse_ch2=ch2
   switch(PyTuple_Size(args)){
   case 0: break;
   default:
-    if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2))
+    if (!PyArg_ParseTuple(args,"kk;vertint,horint", &parse_ch1, &parse_ch2))
       return NULL;
   }
+  ch1 = parse_ch1;
+  ch2 = parse_ch2;
   box(self->win,ch1,ch2);
   Py_INCREF(Py_None);
   return Py_None;
@@ -682,6 +697,7 @@
   PyObject *temp;
   chtype ch;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 1:
@@ -689,7 +705,7 @@
       return NULL;
     break;
   case 2:
-    if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+    if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &parse_attr))
       return NULL;
     break;
   default:
@@ -698,6 +714,7 @@
 
     return NULL;
   }
+  attr = parse_attr;
 
   if (!PyCurses_ConvertToChtype(temp, &ch)) {
     PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
@@ -853,6 +870,7 @@
   chtype ch;
   int n, x, y, code = OK;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 2:
@@ -860,7 +878,7 @@
       return NULL;
     break;
   case 3:
-    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
+    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &parse_attr))
       return NULL;
     break;
   case 4:
@@ -870,7 +888,7 @@
     break;
   case 5:
     if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", 
-		     &y, &x, &temp, &n, &attr))
+		     &y, &x, &temp, &n, &parse_attr))
       return NULL;
     code = wmove(self->win, y, x);
     break;
@@ -878,6 +896,7 @@
     PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (code != ERR) {
     if (!PyCurses_ConvertToChtype(temp, &ch)) {
@@ -897,6 +916,7 @@
   PyObject *temp;
   chtype ch = 0;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
   
   switch (PyTuple_Size(args)) {
   case 1:
@@ -904,7 +924,7 @@
       return NULL;
     break;
   case 2:
-    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
+    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &parse_attr))
       return NULL;
     break;
   case 3:
@@ -913,7 +933,7 @@
     use_xy = TRUE;
     break;
   case 4:
-    if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &attr))
+    if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &parse_attr))
       return NULL;
     use_xy = TRUE;
     break;
@@ -921,6 +941,7 @@
     PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (!PyCurses_ConvertToChtype(temp, &ch)) {
     PyErr_SetString(PyExc_TypeError, 
@@ -1000,6 +1021,7 @@
   char *str;
   attr_t attr = A_NORMAL , attr_old = A_NORMAL;
   int use_xy = FALSE, use_attr = FALSE;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 1:
@@ -1007,7 +1029,7 @@
       return NULL;
     break;
   case 2:
-    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
+    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &parse_attr))
       return NULL;
     use_attr = TRUE;
     break;
@@ -1017,7 +1039,7 @@
     use_xy = TRUE;
     break;
   case 4:
-    if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &attr))
+    if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &parse_attr))
       return NULL;
     use_xy = use_attr = TRUE;
     break;
@@ -1025,6 +1047,7 @@
     PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (use_attr == TRUE) {
     attr_old = getattrs(self->win);
@@ -1046,6 +1069,7 @@
   char *str;
   attr_t attr = A_NORMAL , attr_old = A_NORMAL;
   int use_xy = FALSE, use_attr = FALSE;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 2:
@@ -1053,7 +1077,7 @@
       return NULL;
     break;
   case 3:
-    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
+    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &parse_attr))
       return NULL;
     use_attr = TRUE;
     break;
@@ -1063,7 +1087,8 @@
     use_xy = TRUE;
     break;
   case 5:
-    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
+    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n,
+                          &parse_attr))
       return NULL;
     use_xy = use_attr = TRUE;
     break;
@@ -1071,6 +1096,7 @@
     PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (use_attr == TRUE) {
     attr_old = getattrs(self->win);
@@ -1380,6 +1406,7 @@
   chtype ch;
   int n, x, y, code = OK;
   attr_t attr = A_NORMAL;
+  long parse_attr = attr;
 
   switch (PyTuple_Size(args)) {
   case 2:
@@ -1387,7 +1414,7 @@
       return NULL;
     break;
   case 3:
-    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
+    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &parse_attr))
       return NULL;
     break;
   case 4:
@@ -1397,7 +1424,7 @@
     break;
   case 5:
     if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", 
-		     &y, &x, &temp, &n, &attr))
+		     &y, &x, &temp, &n, &parse_attr))
       return NULL;
     code = wmove(self->win, y, x);
     break;
@@ -1405,6 +1432,7 @@
     PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments");
     return NULL;
   }
+  attr = parse_attr;
 
   if (code != ERR) {
     if (!PyCurses_ConvertToChtype(temp, &ch)) {
@@ -1672,13 +1700,15 @@
 PyCurses_UngetMouse(PyObject *self, PyObject *args)
 {
 	MEVENT event;
+	long parse_event_bstate; /* note: MEVENT.bstate is a mmask_t = ulong */
 
 	PyCursesInitialised
 	if (!PyArg_ParseTuple(args, "(hiiil)",
 			     &event.id, 
 			     &event.x, &event.y, &event.z,
-			     (int *) &event.bstate))
+			     &parse_event_bstate))
 	  return NULL;
+	event.bstate = parse_event_bstate;
 
 	return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
 }
@@ -1713,7 +1743,7 @@
 
   PyCursesInitialised
 
-  if (!PyArg_ParseTuple(args, "b:halfdelay", &tenths)) return NULL;
+  if (!PyArg_ParseTuple(args, "B:halfdelay", &tenths)) return NULL;
 
   return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
 }
Index: Modules/fcntlmodule.c
===================================================================
--- Modules/fcntlmodule.c	(revision 41738)
+++ Modules/fcntlmodule.c	(working copy)
@@ -95,7 +95,7 @@
 {
 	int fd;
 	int code;
-	int arg;
+	int argintbuf;
 	int ret;
 	char *str;
 	int len;
@@ -170,18 +170,18 @@
 	}
 
 	PyErr_Clear();
-	arg = 0;
+	argintbuf = 0;
 	if (!PyArg_ParseTuple(args,
 	     "O&I|i;ioctl requires a file or file descriptor,"
 	     " an integer and optionally an integer or buffer argument",
-			      conv_descriptor, &fd, &code, &arg)) {
+			      conv_descriptor, &fd, &code, &argintbuf)) {
 	  return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
 #ifdef __VMS
-	ret = ioctl(fd, code, (void *)arg);
+	ret = ioctl(fd, code, (void *)argintbuf);
 #else
-	ret = ioctl(fd, code, arg);
+	ret = ioctl(fd, code, argintbuf);
 #endif
 	Py_END_ALLOW_THREADS
 	if (ret < 0) {
Index: Modules/puremodule.c
===================================================================
--- Modules/puremodule.c	(revision 41738)
+++ Modules/puremodule.c	(working copy)
@@ -563,7 +563,7 @@
 	char* type;
 	int status;
 
-	if (!PyArg_ParseTuple(args, "lis:purify_watch_n", &addrrep, &size, &type))
+	if (!PyArg_ParseTuple(args, "lIs:purify_watch_n", &addrrep, &size, &type))
 		return NULL;
 
 	status = purify_watch_n((char*)addrrep, size, type);
@@ -614,7 +614,7 @@
 	unsigned int size;
 	int status;
     
-	if (!PyArg_ParseTuple(args, "li:purify_what_colors", &addrrep, &size))
+	if (!PyArg_ParseTuple(args, "lI:purify_what_colors", &addrrep, &size))
 		return NULL;
 
 	status = purify_what_colors((char*)addrrep, size);
Index: Modules/_hashopenssl.c
===================================================================
--- Modules/_hashopenssl.c	(revision 41738)
+++ Modules/_hashopenssl.c	(working copy)
@@ -234,7 +234,7 @@
     PyObject *name_obj = NULL;
     char *nameStr;
     unsigned char *cp = NULL;
-    unsigned int len;
+    int len;
     const EVP_MD *digest;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|s#:HASH", kwlist,
@@ -371,7 +371,7 @@
     char *name;
     const EVP_MD *digest;
     unsigned char *cp = NULL;
-    unsigned int len;
+    int len;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwdict, "O|s#:new", kwlist,
                                      &name_obj, &cp, &len)) {