]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.307
- new
[packages/vim.git] / 7.3.307
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.307
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.307
11 Problem:    Python 3 doesn't support slice assignment.
12 Solution:   Implement slices. (Brett Overesch, Roland Puntaier)
13 Files:      src/if_python3.c
14
15
16 *** ../vim-7.3.306/src/if_python3.c     2011-08-28 16:00:14.000000000 +0200
17 --- src/if_python3.c    2011-09-14 15:01:26.000000000 +0200
18 ***************
19 *** 855,862 ****
20   
21   static Py_ssize_t BufferLength(PyObject *);
22   static PyObject *BufferItem(PyObject *, Py_ssize_t);
23 ! static PyObject* BufferSubscript(PyObject *self, PyObject* idx);
24 ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val);
25   
26   
27   /* Line range type - Implementation functions
28 --- 855,862 ----
29   
30   static Py_ssize_t BufferLength(PyObject *);
31   static PyObject *BufferItem(PyObject *, Py_ssize_t);
32 ! static PyObject* BufferSubscript(PyObject *self, PyObject *idx);
33 ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
34   
35   
36   /* Line range type - Implementation functions
37 ***************
38 *** 865,872 ****
39   
40   #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
41   
42 ! static PyObject* RangeSubscript(PyObject *self, PyObject* idx);
43   static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
44   
45   /* Current objects type - Implementation functions
46    * -----------------------------------------------
47 --- 865,873 ----
48   
49   #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
50   
51 ! static PyObject* RangeSubscript(PyObject *self, PyObject *idx);
52   static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
53 + static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
54   
55   /* Current objects type - Implementation functions
56    * -----------------------------------------------
57 ***************
58 *** 1035,1041 ****
59               &step, &slicelen) < 0) {
60             return NULL;
61         }
62 !       return BufferSlice(self,start,stop);
63       } else {
64         PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
65         return NULL;
66 --- 1036,1042 ----
67               &step, &slicelen) < 0) {
68             return NULL;
69         }
70 !       return BufferSlice(self, start, stop);
71       } else {
72         PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
73         return NULL;
74 ***************
75 *** 1084,1090 ****
76   PyMappingMethods RangeAsMapping = {
77       /* mp_length      */ (lenfunc)RangeLength,
78       /* mp_subscript     */ (binaryfunc)RangeSubscript,
79 !     /* mp_ass_subscript */ (objobjargproc)0,
80   };
81   
82   /* Line range object - Implementation
83 --- 1085,1091 ----
84   PyMappingMethods RangeAsMapping = {
85       /* mp_length      */ (lenfunc)RangeLength,
86       /* mp_subscript     */ (binaryfunc)RangeSubscript,
87 !     /* mp_ass_subscript */ (objobjargproc)RangeAsSubscript,
88   };
89   
90   /* Line range object - Implementation
91 ***************
92 *** 1123,1128 ****
93 --- 1124,1138 ----
94                     &((RangeObject *)(self))->end);
95   }
96   
97 +     static Py_ssize_t
98 + RangeAsSlice(PyObject *self, Py_ssize_t lo, Py_ssize_t hi, PyObject *val)
99 + {
100 +     return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val,
101 +                   ((RangeObject *)(self))->start,
102 +                   ((RangeObject *)(self))->end,
103 +                   &((RangeObject *)(self))->end);
104 + }
105
106       static PyObject *
107   RangeSubscript(PyObject *self, PyObject* idx)
108   {
109 ***************
110 *** 1138,1150 ****
111                 &step, &slicelen) < 0) {
112             return NULL;
113         }
114 !       return RangeSlice(self,start,stop+1);
115       } else {
116         PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
117         return NULL;
118       }
119   }
120   
121   /* Buffer list object - Definitions
122    */
123   
124 --- 1148,1183 ----
125                 &step, &slicelen) < 0) {
126             return NULL;
127         }
128 !       return RangeSlice(self, start, stop);
129       } else {
130         PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
131         return NULL;
132       }
133   }
134   
135 +     static Py_ssize_t
136 + RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
137 + {
138 +     if (PyLong_Check(idx)) {
139 +       long n = PyLong_AsLong(idx);
140 +       return RangeAsItem(self, n, val);
141 +     } else if (PySlice_Check(idx)) {
142 +       Py_ssize_t start, stop, step, slicelen;
143
144 +       if (PySlice_GetIndicesEx((PySliceObject *)idx,
145 +               ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
146 +               &start, &stop,
147 +               &step, &slicelen) < 0) {
148 +           return -1;
149 +       }
150 +       return RangeAsSlice(self, start, stop, val);
151 +     } else {
152 +       PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
153 +       return -1;
154 +     }
155 + }
156
157
158   /* Buffer list object - Definitions
159    */
160   
161 *** ../vim-7.3.306/src/version.c        2011-09-14 14:43:21.000000000 +0200
162 --- src/version.c       2011-09-14 14:58:16.000000000 +0200
163 ***************
164 *** 711,712 ****
165 --- 711,714 ----
166   {   /* Add new patch number below this line */
167 + /**/
168 +     307,
169   /**/
170
171 -- 
172 The process for understanding customers primarily involves sitting around with
173 other marketing people and talking about what you would to if you were dumb
174 enough to be a customer.
175                                 (Scott Adams - The Dilbert principle)
176
177  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
178 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
179 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
180  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.045817 seconds and 3 git commands to generate.