summaryrefslogtreecommitdiff
path: root/extra/swig/swig-pyslice.patch
blob: e615b5d030d251fa48c374c6e35f251410c3883a (plain)
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
diff -Naur swig-2.0.2.ori/Lib/python/pycontainer.swg swig-2.0.2/Lib/python/pycontainer.swg
--- swig-2.0.2.ori/Lib/python/pycontainer.swg	2010-10-19 02:31:31.000000000 -0400
+++ swig-2.0.2/Lib/python/pycontainer.swg	2011-03-16 20:41:28.090000004 -0400
@@ -630,6 +630,7 @@
       return x;
     }
 
+#if !NO_PYSLICE
     /* typemap for slice object support */
     %typemap(in) PySliceObject* {
       $1 = (PySliceObject *) $input;
@@ -637,6 +638,7 @@
     %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* {
       $1 = PySlice_Check($input);
     }
+#endif
 
     Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
       return swig::getslice(self, i, j);
@@ -659,7 +661,11 @@
     /* Overloaded methods for Python 3 compatibility 
      * (Also useful in Python 2.x)
      */
+#if NO_PYSLICE
+    Sequence* __getitem__(PyObject *slice) throw (std::out_of_range) {
+#else
     Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
+#endif
       Py_ssize_t i, j, step;
       if( !PySlice_Check(slice) ) {
         SWIG_Error(SWIG_TypeError, "Slice object expected.");
@@ -669,7 +675,11 @@
       return swig::getslice(self, i, j);
     }
 
+#if NO_PYSLICE
+    void __setitem__(PyObject *slice, const Sequence& v)
+#else
     void __setitem__(PySliceObject *slice, const Sequence& v)
+#endif
       throw (std::out_of_range, std::invalid_argument) {
       Py_ssize_t i, j, step;
       if( !PySlice_Check(slice) ) {
@@ -680,7 +690,11 @@
       swig::setslice(self, i, j, v);
     }
 
+#if NO_PYSLICE
+    void __delitem__(PyObject *slice)
+#else
     void __delitem__(PySliceObject *slice)
+#endif
       throw (std::out_of_range) {
       Py_ssize_t i, j, step;
       if( !PySlice_Check(slice) ) {
diff -Naur swig-2.0.2.ori/Source/Modules/python.cxx swig-2.0.2/Source/Modules/python.cxx
--- swig-2.0.2.ori/Source/Modules/python.cxx	2011-02-20 08:47:14.000000000 -0500
+++ swig-2.0.2/Source/Modules/python.cxx	2011-03-16 20:40:01.223333338 -0400
@@ -440,6 +440,7 @@
     if (py3) {
         /* force disable features that not compatible with Python 3.x */
         classic = 0;
+        Preprocessor_define((DOH *) "NO_PYSLICE 1", 0);
     }
 
     if (cppcast) {