code.error_goto_if_null(self.result(), self.pos)))
else:
code.putln(
- "%s = PySequence_GetSlice(%s, %s, %s); %s" % (
+ "%s = __Pyx_PySequence_GetSlice(%s, %s, %s); %s" % (
self.result(),
self.base.py_result(),
self.start_code(),
self.generate_subexpr_evaluation_code(code)
if self.type.is_pyobject:
code.put_error_if_neg(self.pos,
- "PySequence_SetSlice(%s, %s, %s, %s)" % (
+ "__Pyx_PySequence_SetSlice(%s, %s, %s, %s)" % (
self.base.py_result(),
self.start_code(),
self.stop_code(),
return
self.generate_subexpr_evaluation_code(code)
code.put_error_if_neg(self.pos,
- "PySequence_DelSlice(%s, %s, %s)" % (
+ "__Pyx_PySequence_DelSlice(%s, %s, %s)" % (
self.base.py_result(),
self.start_code(),
self.stop_code()))
code.putln("#endif")
code.put("""
+#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
+ #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
+ #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
+ #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
+#else
+ #define __Pyx_PySequence_GetSlice(obj, a, b) ((!(obj)) ? \\
+ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \\
+ (((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \\
+ (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
+ #define __Pyx_PySequence_SetSlice(obj, a, b, value) ((!(obj)) ? \\
+ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \\
+ (((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \\
+ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
+ #define __Pyx_PySequence_DelSlice(obj, a, b) ((!(obj)) ? \\
+ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \\
+ (((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \\
+ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
+#endif
+
#if PY_MAJOR_VERSION >= 3
#define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
True
>>> l is f(1, l, 2, 3)
False
+ >>> f(1, 42, 2, 3)
+ Traceback (most recent call last):
+ TypeError: 'int' object is unsliceable
"""
obj1 = obj2[:]
return obj1
"""
>>> g(1, [1,2,3,4], 2, 3)
[3, 4]
+ >>> g(1, 42, 2, 3)
+ Traceback (most recent call last):
+ TypeError: 'int' object is unsliceable
"""
obj1 = obj2[obj3:]
return obj1
"""
>>> h(1, [1,2,3,4], 2, 3)
[1, 2, 3]
+ >>> h(1, 42, 2, 3)
+ Traceback (most recent call last):
+ TypeError: 'int' object is unsliceable
"""
obj1 = obj2[:obj4]
return obj1
"""
>>> j(1, [1,2,3,4], 2, 3)
[3]
+ >>> j(1, 42, 2, 3)
+ Traceback (most recent call last):
+ TypeError: 'int' object is unsliceable
"""
obj1 = obj2[obj3:obj4]
return obj1