Karsten Hopp 781234
To: vim_dev@googlegroups.com
Karsten Hopp 781234
Subject: Patch 7.3.307
Karsten Hopp 781234
Fcc: outbox
Karsten Hopp 781234
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 781234
Mime-Version: 1.0
Karsten Hopp 781234
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 781234
Content-Transfer-Encoding: 8bit
Karsten Hopp 781234
------------
Karsten Hopp 781234
Karsten Hopp 781234
Patch 7.3.307
Karsten Hopp 781234
Problem:    Python 3 doesn't support slice assignment.
Karsten Hopp 781234
Solution:   Implement slices. (Brett Overesch, Roland Puntaier)
Karsten Hopp 781234
Files:	    src/if_python3.c
Karsten Hopp 781234
Karsten Hopp 781234
Karsten Hopp 781234
*** ../vim-7.3.306/src/if_python3.c	2011-08-28 16:00:14.000000000 +0200
Karsten Hopp 781234
--- src/if_python3.c	2011-09-14 15:01:26.000000000 +0200
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 855,862 ****
Karsten Hopp 781234
  
Karsten Hopp 781234
  static Py_ssize_t BufferLength(PyObject *);
Karsten Hopp 781234
  static PyObject *BufferItem(PyObject *, Py_ssize_t);
Karsten Hopp 781234
! static PyObject* BufferSubscript(PyObject *self, PyObject* idx);
Karsten Hopp 781234
! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val);
Karsten Hopp 781234
  
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Line range type - Implementation functions
Karsten Hopp 781234
--- 855,862 ----
Karsten Hopp 781234
  
Karsten Hopp 781234
  static Py_ssize_t BufferLength(PyObject *);
Karsten Hopp 781234
  static PyObject *BufferItem(PyObject *, Py_ssize_t);
Karsten Hopp 781234
! static PyObject* BufferSubscript(PyObject *self, PyObject *idx);
Karsten Hopp 781234
! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
Karsten Hopp 781234
  
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Line range type - Implementation functions
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 865,872 ****
Karsten Hopp 781234
  
Karsten Hopp 781234
  #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
Karsten Hopp 781234
  
Karsten Hopp 781234
! static PyObject* RangeSubscript(PyObject *self, PyObject* idx);
Karsten Hopp 781234
  static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Current objects type - Implementation functions
Karsten Hopp 781234
   * -----------------------------------------------
Karsten Hopp 781234
--- 865,873 ----
Karsten Hopp 781234
  
Karsten Hopp 781234
  #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
Karsten Hopp 781234
  
Karsten Hopp 781234
! static PyObject* RangeSubscript(PyObject *self, PyObject *idx);
Karsten Hopp 781234
  static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
Karsten Hopp 781234
+ static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Current objects type - Implementation functions
Karsten Hopp 781234
   * -----------------------------------------------
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 1035,1041 ****
Karsten Hopp 781234
  	      &step, &slicelen) < 0) {
Karsten Hopp 781234
  	    return NULL;
Karsten Hopp 781234
  	}
Karsten Hopp 781234
! 	return BufferSlice(self,start,stop);
Karsten Hopp 781234
      } else {
Karsten Hopp 781234
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
Karsten Hopp 781234
  	return NULL;
Karsten Hopp 781234
--- 1036,1042 ----
Karsten Hopp 781234
  	      &step, &slicelen) < 0) {
Karsten Hopp 781234
  	    return NULL;
Karsten Hopp 781234
  	}
Karsten Hopp 781234
! 	return BufferSlice(self, start, stop);
Karsten Hopp 781234
      } else {
Karsten Hopp 781234
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
Karsten Hopp 781234
  	return NULL;
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 1084,1090 ****
Karsten Hopp 781234
  PyMappingMethods RangeAsMapping = {
Karsten Hopp 781234
      /* mp_length	*/ (lenfunc)RangeLength,
Karsten Hopp 781234
      /* mp_subscript     */ (binaryfunc)RangeSubscript,
Karsten Hopp 781234
!     /* mp_ass_subscript */ (objobjargproc)0,
Karsten Hopp 781234
  };
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Line range object - Implementation
Karsten Hopp 781234
--- 1085,1091 ----
Karsten Hopp 781234
  PyMappingMethods RangeAsMapping = {
Karsten Hopp 781234
      /* mp_length	*/ (lenfunc)RangeLength,
Karsten Hopp 781234
      /* mp_subscript     */ (binaryfunc)RangeSubscript,
Karsten Hopp 781234
!     /* mp_ass_subscript */ (objobjargproc)RangeAsSubscript,
Karsten Hopp 781234
  };
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Line range object - Implementation
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 1123,1128 ****
Karsten Hopp 781234
--- 1124,1138 ----
Karsten Hopp 781234
  		    &((RangeObject *)(self))->end);
Karsten Hopp 781234
  }
Karsten Hopp 781234
  
Karsten Hopp 781234
+     static Py_ssize_t
Karsten Hopp 781234
+ RangeAsSlice(PyObject *self, Py_ssize_t lo, Py_ssize_t hi, PyObject *val)
Karsten Hopp 781234
+ {
Karsten Hopp 781234
+     return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val,
Karsten Hopp 781234
+ 		    ((RangeObject *)(self))->start,
Karsten Hopp 781234
+ 		    ((RangeObject *)(self))->end,
Karsten Hopp 781234
+ 		    &((RangeObject *)(self))->end);
Karsten Hopp 781234
+ }
Karsten Hopp 781234
+ 
Karsten Hopp 781234
      static PyObject *
Karsten Hopp 781234
  RangeSubscript(PyObject *self, PyObject* idx)
Karsten Hopp 781234
  {
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 1138,1150 ****
Karsten Hopp 781234
  		&step, &slicelen) < 0) {
Karsten Hopp 781234
  	    return NULL;
Karsten Hopp 781234
  	}
Karsten Hopp 781234
! 	return RangeSlice(self,start,stop+1);
Karsten Hopp 781234
      } else {
Karsten Hopp 781234
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
Karsten Hopp 781234
  	return NULL;
Karsten Hopp 781234
      }
Karsten Hopp 781234
  }
Karsten Hopp 781234
  
Karsten Hopp 781234
  /* Buffer list object - Definitions
Karsten Hopp 781234
   */
Karsten Hopp 781234
  
Karsten Hopp 781234
--- 1148,1183 ----
Karsten Hopp 781234
  		&step, &slicelen) < 0) {
Karsten Hopp 781234
  	    return NULL;
Karsten Hopp 781234
  	}
Karsten Hopp 781234
! 	return RangeSlice(self, start, stop);
Karsten Hopp 781234
      } else {
Karsten Hopp 781234
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
Karsten Hopp 781234
  	return NULL;
Karsten Hopp 781234
      }
Karsten Hopp 781234
  }
Karsten Hopp 781234
  
Karsten Hopp 781234
+     static Py_ssize_t
Karsten Hopp 781234
+ RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
Karsten Hopp 781234
+ {
Karsten Hopp 781234
+     if (PyLong_Check(idx)) {
Karsten Hopp 781234
+ 	long n = PyLong_AsLong(idx);
Karsten Hopp 781234
+ 	return RangeAsItem(self, n, val);
Karsten Hopp 781234
+     } else if (PySlice_Check(idx)) {
Karsten Hopp 781234
+ 	Py_ssize_t start, stop, step, slicelen;
Karsten Hopp 781234
+ 
Karsten Hopp 781234
+ 	if (PySlice_GetIndicesEx((PySliceObject *)idx,
Karsten Hopp 781234
+ 		((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
Karsten Hopp 781234
+ 		&start, &stop,
Karsten Hopp 781234
+ 		&step, &slicelen) < 0) {
Karsten Hopp 781234
+ 	    return -1;
Karsten Hopp 781234
+ 	}
Karsten Hopp 781234
+ 	return RangeAsSlice(self, start, stop, val);
Karsten Hopp 781234
+     } else {
Karsten Hopp 781234
+ 	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
Karsten Hopp 781234
+ 	return -1;
Karsten Hopp 781234
+     }
Karsten Hopp 781234
+ }
Karsten Hopp 781234
+ 
Karsten Hopp 781234
+ 
Karsten Hopp 781234
  /* Buffer list object - Definitions
Karsten Hopp 781234
   */
Karsten Hopp 781234
  
Karsten Hopp 781234
*** ../vim-7.3.306/src/version.c	2011-09-14 14:43:21.000000000 +0200
Karsten Hopp 781234
--- src/version.c	2011-09-14 14:58:16.000000000 +0200
Karsten Hopp 781234
***************
Karsten Hopp 781234
*** 711,712 ****
Karsten Hopp 781234
--- 711,714 ----
Karsten Hopp 781234
  {   /* Add new patch number below this line */
Karsten Hopp 781234
+ /**/
Karsten Hopp 781234
+     307,
Karsten Hopp 781234
  /**/
Karsten Hopp 781234
Karsten Hopp 781234
-- 
Karsten Hopp 781234
The process for understanding customers primarily involves sitting around with
Karsten Hopp 781234
other marketing people and talking about what you would to if you were dumb
Karsten Hopp 781234
enough to be a customer.
Karsten Hopp 781234
				(Scott Adams - The Dilbert principle)
Karsten Hopp 781234
Karsten Hopp 781234
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 781234
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 781234
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 781234
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///