Hello community, here is the log from the commit of package python-Cython for openSUSE:Factory checked in at 2020-05-04 18:32:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-Cython (Old) and /work/SRC/openSUSE:Factory/.python-Cython.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-Cython" Mon May 4 18:32:59 2020 rev:54 rq:799980 version:0.29.17 Changes: -------- --- /work/SRC/openSUSE:Factory/python-Cython/python-Cython.changes 2020-04-22 20:42:07.346115404 +0200 +++ /work/SRC/openSUSE:Factory/.python-Cython.new.2738/python-Cython.changes 2020-05-04 18:33:32.176197951 +0200 @@ -1,0 +2,7 @@ +Mon May 4 07:29:52 UTC 2020 - Johannes Grassler <[email protected]> + +- update to 0.29.17 + * std::move() is now available from libcpp.utility. + * The @cython.binding decorator is available in Python code. + +------------------------------------------------------------------- Old: ---- Cython-0.29.16.tar.gz New: ---- Cython-0.29.17.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-Cython.spec ++++++ --- /var/tmp/diff_new_pack.cMsWxI/_old 2020-05-04 18:33:33.948201542 +0200 +++ /var/tmp/diff_new_pack.cMsWxI/_new 2020-05-04 18:33:33.952201550 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define oldpython python Name: python-Cython -Version: 0.29.16 +Version: 0.29.17 Release: 0 Summary: The Cython compiler for writing C extensions for the Python language License: Apache-2.0 ++++++ Cython-0.29.16.tar.gz -> Cython-0.29.17.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/.gitrev new/Cython-0.29.17/.gitrev --- old/Cython-0.29.16/.gitrev 2020-03-24 15:54:53.000000000 +0100 +++ new/Cython-0.29.17/.gitrev 2020-04-26 16:37:31.000000000 +0200 @@ -1 +1 @@ -c8425604fc3e4ea846016689942fa98e886b5f4f +b648b65ac39291aa546b58e44c8576869c351b66 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/CHANGES.rst new/Cython-0.29.17/CHANGES.rst --- old/Cython-0.29.16/CHANGES.rst 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/CHANGES.rst 2020-04-26 16:37:12.000000000 +0200 @@ -2,6 +2,49 @@ Cython Changelog ================ +0.29.17 (2020-04-26) +==================== + +Features added +-------------- + +* ``std::move()`` is now available from ``libcpp.utility``. + Patch by Omer Ozarslan. (Github issue #2169) + +* The ``@cython.binding`` decorator is available in Python code. + (Github issue #3505) + +Bugs fixed +---------- + +* Creating an empty unicode slice with large bounds could crash. + Patch by Sam Sneddon. (Github issue #3531) + +* Decoding an empty bytes/char* slice with large bounds could crash. + Patch by Sam Sneddon. (Github issue #3534) + +* Re-importing a Cython extension no longer raises the error + "``__reduce_cython__ not found``". + (Github issue #3545) + +* Unused C-tuples could generate incorrect code in 0.29.16. + Patch by Kirk Meyer. (Github issue #3543) + +* Creating a fused function attached it to the garbage collector before it + was fully initialised, thus risking crashes in rare failure cases. + Original patch by achernomorov. (Github issue #3215) + +* Temporary buffer indexing variables were not released and could show up in + C compiler warnings, e.g. in generators. + Patch by David Woods. (Github issues #3430, #3522) + +* The compilation cache in ``cython.inline("…")`` failed to take the language + level into account. + Patch by will-ca. (Github issue #3419) + +* The deprecated ``PyUnicode_GET_SIZE()`` function is no longer used in Py3. + + 0.29.16 (2020-03-24) ==================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Build/Inline.py new/Cython-0.29.17/Cython/Build/Inline.py --- old/Cython-0.29.16/Cython/Build/Inline.py 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/Cython/Build/Inline.py 2020-04-26 16:37:08.000000000 +0200 @@ -144,6 +144,10 @@ else: print("Couldn't find %r" % symbol) +def _inline_key(orig_code, arg_sigs, language_level): + key = orig_code, arg_sigs, sys.version_info, sys.executable, language_level, Cython.__version__ + return hashlib.sha1(_unicode(key).encode('utf-8')).hexdigest() + def cython_inline(code, get_type=unsafe_type, lib_dir=os.path.join(get_cython_cache_dir(), 'inline'), cython_include_dirs=None, cython_compiler_directives=None, @@ -153,13 +157,20 @@ get_type = lambda x: 'object' ctx = _create_context(tuple(cython_include_dirs)) if cython_include_dirs else _cython_inline_default_context + cython_compiler_directives = dict(cython_compiler_directives or {}) + if language_level is None and 'language_level' not in cython_compiler_directives: + language_level = '3str' + if language_level is not None: + cython_compiler_directives['language_level'] = language_level + # Fast path if this has been called in this session. _unbound_symbols = _cython_inline_cache.get(code) if _unbound_symbols is not None: _populate_unbound(kwds, _unbound_symbols, locals, globals) args = sorted(kwds.items()) arg_sigs = tuple([(get_type(value, ctx), arg) for arg, value in args]) - invoke = _cython_inline_cache.get((code, arg_sigs)) + key_hash = _inline_key(code, arg_sigs, language_level) + invoke = _cython_inline_cache.get((code, arg_sigs, key_hash)) if invoke is not None: arg_list = [arg[1] for arg in args] return invoke(*arg_list) @@ -180,10 +191,6 @@ # Parsing from strings not fully supported (e.g. cimports). print("Could not parse code as a string (to extract unbound symbols).") - cython_compiler_directives = dict(cython_compiler_directives or {}) - if language_level is not None: - cython_compiler_directives['language_level'] = language_level - cimports = [] for name, arg in list(kwds.items()): if arg is cython_module: @@ -191,8 +198,8 @@ del kwds[name] arg_names = sorted(kwds) arg_sigs = tuple([(get_type(kwds[arg], ctx), arg) for arg in arg_names]) - key = orig_code, arg_sigs, sys.version_info, sys.executable, language_level, Cython.__version__ - module_name = "_cython_inline_" + hashlib.md5(_unicode(key).encode('utf-8')).hexdigest() + key_hash = _inline_key(orig_code, arg_sigs, language_level) + module_name = "_cython_inline_" + key_hash if module_name in sys.modules: module = sys.modules[module_name] @@ -259,7 +266,7 @@ module = load_dynamic(module_name, module_path) - _cython_inline_cache[orig_code, arg_sigs] = module.__invoke + _cython_inline_cache[orig_code, arg_sigs, key_hash] = module.__invoke arg_list = [kwds[arg] for arg in arg_names] return module.__invoke(*arg_list) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Build/Tests/TestInline.py new/Cython-0.29.17/Cython/Build/Tests/TestInline.py --- old/Cython-0.29.16/Cython/Build/Tests/TestInline.py 2019-05-27 21:37:21.000000000 +0200 +++ new/Cython-0.29.17/Cython/Build/Tests/TestInline.py 2020-04-26 16:37:08.000000000 +0200 @@ -74,6 +74,18 @@ 6 ) + def test_lang_version(self): + # GH-3419. Caching for inline code didn't always respect compiler directives. + inline_divcode = "def f(int a, int b): return a/b" + self.assertEqual( + inline(inline_divcode, language_level=2)['f'](5,2), + 2 + ) + self.assertEqual( + inline(inline_divcode, language_level=3)['f'](5,2), + 2.5 + ) + if has_numpy: def test_numpy(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Compiler/ExprNodes.py new/Cython-0.29.17/Cython/Compiler/ExprNodes.py --- old/Cython-0.29.16/Cython/Compiler/ExprNodes.py 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/Cython/Compiler/ExprNodes.py 2020-04-26 16:37:12.000000000 +0200 @@ -4200,6 +4200,9 @@ # Whether we're assigning to a buffer (in that case it needs to be writable) writable_needed = False + # Any indexing temp variables that we need to clean up. + index_temps = () + def analyse_target_types(self, env): self.analyse_types(env, getting=False) @@ -4284,7 +4287,7 @@ warning(self.pos, "Use boundscheck(False) for faster access", level=1) # Assign indices to temps of at least (s)size_t to allow further index calculations. - index_temps = [self.get_index_in_temp(code,ivar) for ivar in self.indices] + self.index_temps = index_temps = [self.get_index_in_temp(code,ivar) for ivar in self.indices] # Generate buffer access code using these temps from . import Buffer @@ -4370,6 +4373,12 @@ code.putln("%s = (PyObject *) *%s;" % (self.result(), self.buffer_ptr_code)) code.putln("__Pyx_INCREF((PyObject*)%s);" % self.result()) + def free_temps(self, code): + for temp in self.index_temps: + code.funcstate.release_temp(temp) + self.index_temps = () + super(BufferIndexNode, self).free_temps(code) + class MemoryViewIndexNode(BufferIndexNode): @@ -9387,11 +9396,11 @@ if self.specialized_cpdefs or self.is_specialization: code.globalstate.use_utility_code( UtilityCode.load_cached("FusedFunction", "CythonFunction.c")) - constructor = "__pyx_FusedFunction_NewEx" + constructor = "__pyx_FusedFunction_New" else: code.globalstate.use_utility_code( UtilityCode.load_cached("CythonFunction", "CythonFunction.c")) - constructor = "__Pyx_CyFunction_NewEx" + constructor = "__Pyx_CyFunction_New" if self.code_object: code_object_result = self.code_object.py_result() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Compiler/ModuleNode.py new/Cython-0.29.17/Cython/Compiler/ModuleNode.py --- old/Cython-0.29.16/Cython/Compiler/ModuleNode.py 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/Cython/Compiler/ModuleNode.py 2020-04-26 16:37:12.000000000 +0200 @@ -580,7 +580,7 @@ definition = module is env type_entries = [] for entry in module.type_entries: - if entry.type.is_ctuple: + if entry.type.is_ctuple and entry.used: if entry.name not in ctuple_names: ctuple_names.add(entry.name) type_entries.append(entry) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Includes/libcpp/utility.pxd new/Cython-0.29.17/Cython/Includes/libcpp/utility.pxd --- old/Cython-0.29.16/Cython/Includes/libcpp/utility.pxd 2016-12-10 16:41:15.000000000 +0100 +++ new/Cython-0.29.17/Cython/Includes/libcpp/utility.pxd 2020-04-19 11:26:03.000000000 +0200 @@ -13,3 +13,17 @@ bint operator>(pair&, pair&) bint operator<=(pair&, pair&) bint operator>=(pair&, pair&) + +cdef extern from * namespace "cython_std" nogil: + """ + #if __cplusplus > 199711L + #include <type_traits> + + namespace cython_std { + template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); } + template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); } + } + + #endif + """ + cdef T move[T](T) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Shadow.py new/Cython-0.29.17/Cython/Shadow.py --- old/Cython-0.29.16/Cython/Shadow.py 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/Cython/Shadow.py 2020-04-26 16:37:12.000000000 +0200 @@ -1,7 +1,7 @@ # cython.* namespace for pure mode. from __future__ import absolute_import -__version__ = "0.29.16" +__version__ = "0.29.17" try: from __builtin__ import basestring @@ -123,6 +123,8 @@ final = internal = type_version_tag = no_gc_clear = no_gc = _empty_decorator +binding = lambda _: _empty_decorator + _cython_inline = None def inline(f, *args, **kwds): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/CythonFunction.c new/Cython-0.29.17/Cython/Utility/CythonFunction.c --- old/Cython-0.29.16/Cython/Utility/CythonFunction.c 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/Cython/Utility/CythonFunction.c 2020-04-26 16:37:12.000000000 +0200 @@ -1,6 +1,6 @@ +//////////////////// CythonFunctionShared.proto //////////////////// -//////////////////// CythonFunction.proto //////////////////// #define __Pyx_CyFunction_USED 1 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 @@ -50,10 +50,7 @@ #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) -#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \ - __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) - -static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, PyObject *globals, @@ -72,7 +69,8 @@ static int __pyx_CyFunction_init(void); -//////////////////// CythonFunction //////////////////// + +//////////////////// CythonFunctionShared //////////////////// //@substitute: naming //@requires: CommonStructures.c::FetchCommonType ////@requires: ObjectHandling.c::PyObjectGetAttrStr @@ -446,11 +444,9 @@ #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) #endif - -static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { - __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); - if (op == NULL) +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + if (unlikely(op == NULL)) return NULL; op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; @@ -478,7 +474,6 @@ op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; - PyObject_GC_Track(op); return (PyObject *) op; } @@ -779,11 +774,36 @@ Py_INCREF(dict); } + +//////////////////// CythonFunction.proto //////////////////// + +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *closure, + PyObject *module, PyObject *globals, + PyObject* code); + +//////////////////// CythonFunction //////////////////// +//@requires: CythonFunctionShared + +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + PyObject *op = __Pyx_CyFunction_Init( + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + PyObject_GC_Track(op); + } + return op; +} + + //////////////////// CyFunctionClassCell.proto //////////////////// static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/ //////////////////// CyFunctionClassCell //////////////////// -//@requires: CythonFunction +//@requires: CythonFunctionShared static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) { Py_ssize_t i, count = PyList_GET_SIZE(cyfunctions); @@ -806,7 +826,9 @@ return 0; } + //////////////////// FusedFunction.proto //////////////////// + typedef struct { __pyx_CyFunctionObject func; PyObject *__signatures__; @@ -814,11 +836,8 @@ PyObject *self; } __pyx_FusedFunctionObject; -#define __pyx_FusedFunction_NewEx(ml, flags, qualname, self, module, globals, code) \ - __pyx_FusedFunction_New(__pyx_FusedFunctionType, ml, flags, qualname, self, module, globals, code) -static PyObject *__pyx_FusedFunction_New(PyTypeObject *type, - PyMethodDef *ml, int flags, - PyObject *qualname, PyObject *self, +static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags, + PyObject *qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject *code); @@ -829,24 +848,27 @@ #define __Pyx_FusedFunction_USED //////////////////// FusedFunction //////////////////// -//@requires: CythonFunction +//@requires: CythonFunctionShared static PyObject * -__pyx_FusedFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, - PyObject *qualname, PyObject *self, +__pyx_FusedFunction_New(PyMethodDef *ml, int flags, + PyObject *qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject *code) { - __pyx_FusedFunctionObject *fusedfunc = - (__pyx_FusedFunctionObject *) __Pyx_CyFunction_New(type, ml, flags, qualname, - self, module, globals, code); - if (!fusedfunc) - return NULL; - - fusedfunc->__signatures__ = NULL; - fusedfunc->type = NULL; - fusedfunc->self = NULL; - return (PyObject *) fusedfunc; + PyObject *op = __Pyx_CyFunction_Init( + // __pyx_CyFunctionObject is correct below since that's the cast that we want. + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_FusedFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + __pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op; + fusedfunc->__signatures__ = NULL; + fusedfunc->type = NULL; + fusedfunc->self = NULL; + PyObject_GC_Track(op); + } + return op; } static void @@ -896,7 +918,7 @@ if (obj == Py_None) obj = NULL; - meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_NewEx( + meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New( ((PyCFunctionObject *) func)->m_ml, ((__pyx_CyFunctionObject *) func)->flags, ((__pyx_CyFunctionObject *) func)->func_qualname, @@ -972,31 +994,32 @@ if (PyTuple_Check(idx)) { PyObject *list = PyList_New(0); Py_ssize_t n = PyTuple_GET_SIZE(idx); - PyObject *string = NULL; PyObject *sep = NULL; int i; - if (!list) + if (unlikely(!list)) return NULL; for (i = 0; i < n; i++) { + int ret; + PyObject *string; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS PyObject *item = PyTuple_GET_ITEM(idx, i); #else - PyObject *item = PySequence_ITEM(idx, i); + PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err; #endif string = _obj_to_str(item); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(item); #endif - if (!string || PyList_Append(list, string) < 0) - goto __pyx_err; - + if (unlikely(!string)) goto __pyx_err; + ret = PyList_Append(list, string); Py_DECREF(string); + if (unlikely(ret < 0)) goto __pyx_err; } sep = PyUnicode_FromString("|"); - if (sep) + if (likely(sep)) signature = PyUnicode_Join(sep, list); __pyx_err: ; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/ExtensionTypes.c new/Cython-0.29.17/Cython/Utility/ExtensionTypes.c --- old/Cython-0.29.16/Cython/Utility/ExtensionTypes.c 2020-02-06 11:26:34.000000000 +0100 +++ new/Cython-0.29.17/Cython/Utility/ExtensionTypes.c 2020-04-26 16:37:12.000000000 +0200 @@ -132,6 +132,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj); /////////////// SetupReduce /////////////// +//@requires: ObjectHandling.c::PyObjectGetAttrStrNoError //@requires: ObjectHandling.c::PyObjectGetAttrStr //@substitute: naming @@ -188,16 +189,28 @@ reduce = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce__")); if (unlikely(!reduce)) goto __PYX_BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, PYIDENT("__reduce_cython__"))) { - reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__reduce_cython__")); if (unlikely(!reduce_cython)) goto __PYX_BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce__"), reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__reduce_cython__")); + if (likely(reduce_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce__"), reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__reduce_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (reduce == object_reduce || PyErr_Occurred()) { + // Ignore if we're done, i.e. if 'reduce' already has the right name and the original is gone. + // Otherwise: error. + goto __PYX_BAD; + } setstate = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__setstate__")); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, PYIDENT("__setstate_cython__"))) { - setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, PYIDENT("__setstate_cython__")); if (unlikely(!setstate_cython)) goto __PYX_BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate__"), setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__setstate_cython__")); + if (likely(setstate_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate__"), setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, PYIDENT("__setstate_cython__")); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (!setstate || PyErr_Occurred()) { + // Ignore if we're done, i.e. if 'setstate' already has the right name and the original is gone. + // Otherwise: error. + goto __PYX_BAD; + } } PyType_Modified((PyTypeObject*)type_obj); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/FunctionArguments.c new/Cython-0.29.17/Cython/Utility/FunctionArguments.c --- old/Cython-0.29.16/Cython/Utility/FunctionArguments.c 2018-09-22 16:18:56.000000000 +0200 +++ new/Cython-0.29.17/Cython/Utility/FunctionArguments.c 2020-04-26 16:37:08.000000000 +0200 @@ -211,7 +211,7 @@ name = first_kw_arg; #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + if (likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { @@ -239,9 +239,9 @@ while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif - // need to convert argument name from bytes to unicode for comparison + // In Py2, we may need to convert the argument name from str to unicode for comparison. PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { @@ -257,7 +257,7 @@ while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif // need to convert argument name from bytes to unicode for comparison PyUnicode_Compare(**argname, key); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/ImportExport.c new/Cython-0.29.17/Cython/Utility/ImportExport.c --- old/Cython-0.29.16/Cython/Utility/ImportExport.c 2018-11-24 10:20:06.000000000 +0100 +++ new/Cython-0.29.17/Cython/Utility/ImportExport.c 2020-04-26 16:37:12.000000000 +0200 @@ -46,7 +46,8 @@ { #if PY_MAJOR_VERSION >= 3 if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { + // Avoid C compiler warning if strchr() evaluates to false at compile time. + if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { /* try package relative import first */ module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/ObjectHandling.c new/Cython-0.29.17/Cython/Utility/ObjectHandling.c --- old/Cython-0.29.16/Cython/Utility/ObjectHandling.c 2019-07-07 10:37:19.000000000 +0200 +++ new/Cython-0.29.17/Cython/Utility/ObjectHandling.c 2020-04-26 16:37:12.000000000 +0200 @@ -1361,6 +1361,41 @@ #endif +/////////////// PyObjectGetAttrStrNoError.proto /////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);/*proto*/ + +/////////////// PyObjectGetAttrStrNoError /////////////// +//@requires: PyObjectGetAttrStr +//@requires: Exceptions.c::PyThreadStateGet +//@requires: Exceptions.c::PyErrFetchRestore +//@requires: Exceptions.c::PyErrExceptionMatches + +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 + // _PyObject_GenericGetAttrWithDict() in CPython 3.7+ can avoid raising the AttributeError. + // See https://bugs.python.org/issue32544 + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +} + + /////////////// PyObjectGetAttrStr.proto /////////////// #if CYTHON_USE_TYPE_SLOTS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/Cython/Utility/StringTools.c new/Cython-0.29.17/Cython/Utility/StringTools.c --- old/Cython-0.29.16/Cython/Utility/StringTools.c 2019-01-19 10:25:16.000000000 +0100 +++ new/Cython-0.29.17/Cython/Utility/StringTools.c 2020-04-26 16:37:12.000000000 +0200 @@ -466,9 +466,9 @@ if (stop < 0) stop += length; } - length = stop - start; - if (unlikely(length <= 0)) + if (unlikely(stop <= start)) return PyUnicode_FromUnicode(NULL, 0); + length = stop - start; cstring += start; if (decode_func) { return decode_func(cstring, length, errors); @@ -502,9 +502,9 @@ } if (stop > length) stop = length; - length = stop - start; - if (unlikely(length <= 0)) + if (unlikely(stop <= start)) return PyUnicode_FromUnicode(NULL, 0); + length = stop - start; cstring += start; if (decode_func) { return decode_func(cstring, length, errors); @@ -558,8 +558,7 @@ stop += length; else if (stop > length) stop = length; - length = stop - start; - if (length <= 0) + if (stop <= start) return PyUnicode_FromUnicode(NULL, 0); #if CYTHON_PEP393_ENABLED return PyUnicode_FromKindAndData(PyUnicode_KIND(text), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/PKG-INFO new/Cython-0.29.17/PKG-INFO --- old/Cython-0.29.16/PKG-INFO 2020-03-24 15:55:01.000000000 +0100 +++ new/Cython-0.29.17/PKG-INFO 2020-04-26 16:37:40.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: Cython -Version: 0.29.16 +Version: 0.29.17 Summary: The Cython compiler for writing C extensions for the Python language. Home-page: http://cython.org/ Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. @@ -21,8 +21,9 @@ Python code. Note that for one-time builds, e.g. for CI/testing, on platforms that are not - covered by one of the wheel packages provided on PyPI, it is substantially faster - than a full source build to install an uncompiled (slower) version of Cython with:: + covered by one of the wheel packages provided on PyPI *and* the pure Python wheel + that we provide is not used, it is substantially faster than a full source build + to install an uncompiled (slower) version of Cython with:: pip install Cython --install-option="--no-cython-compile" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/docs/src/userguide/external_C_code.rst new/Cython-0.29.17/docs/src/userguide/external_C_code.rst --- old/Cython-0.29.16/docs/src/userguide/external_C_code.rst 2018-11-24 10:20:06.000000000 +0100 +++ new/Cython-0.29.17/docs/src/userguide/external_C_code.rst 2020-04-26 16:37:12.000000000 +0200 @@ -17,7 +17,7 @@ Cython module can be used as a bridge to allow Python code to call C code, it can also be used to allow C code to call Python code. -.. _embedding Python: http://www.freenet.org.nz/python/embeddingpyrex/ +.. _embedding Python: https://web.archive.org/web/20120225082358/http://www.freenet.org.nz:80/python/embeddingpyrex/ External declarations ======================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/runtests.py new/Cython-0.29.17/runtests.py --- old/Cython-0.29.16/runtests.py 2020-02-06 11:26:34.000000000 +0100 +++ new/Cython-0.29.17/runtests.py 2020-04-26 16:37:12.000000000 +0200 @@ -424,6 +424,7 @@ # to be unsafe... (2,999): (operator.lt, lambda x: x in ['run.special_methods_T561_py3', 'run.test_raisefrom', + 'run.reimport_failure', # reimports don't do anything in Py2 ]), (3,): (operator.ge, lambda x: x in ['run.non_future_division', 'compile.extsetslice', @@ -1095,6 +1096,11 @@ from Cython.Build.Dependencies import update_pythran_extension update_pythran_extension(extension) + # Compile with -DCYTHON_CLINE_IN_TRACEBACK=1 unless we have + # the "traceback" tag + if 'traceback' not in self.tags['tag']: + extension.define_macros.append(("CYTHON_CLINE_IN_TRACEBACK", 1)) + for matcher, fixer in list(EXT_EXTRAS.items()): if isinstance(matcher, str): # lazy init diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/setup.cfg new/Cython-0.29.17/setup.cfg --- old/Cython-0.29.16/setup.cfg 2020-02-13 18:26:02.000000000 +0100 +++ new/Cython-0.29.17/setup.cfg 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -[flake8] -max-complexity = 10 - -[pycodestyle] -exclude = .git,build,__pycache__,venv*,TEST* -max-line-length = 150 -format = pylint -select = E711, E714, E501, W291 -#ignore = W, E -ignore = - W504, - # W504 line break after binary operator - S001, - # S001 found module formatter - E226, - # E226 missing whitespace around operator[run] - -[coverage:run] -branch = True -parallel = True -concurrency = multiprocessing,thread -include = Cython/* -source = Cython -omit = Test* - -[bdist_wheel] -universal = 1 - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/setup.py new/Cython-0.29.17/setup.py --- old/Cython-0.29.16/setup.py 2020-03-24 15:54:39.000000000 +0100 +++ new/Cython-0.29.17/setup.py 2020-04-26 16:37:12.000000000 +0200 @@ -248,8 +248,9 @@ Python code. Note that for one-time builds, e.g. for CI/testing, on platforms that are not - covered by one of the wheel packages provided on PyPI, it is substantially faster - than a full source build to install an uncompiled (slower) version of Cython with:: + covered by one of the wheel packages provided on PyPI *and* the pure Python wheel + that we provide is not used, it is substantially faster than a full source build + to install an uncompiled (slower) version of Cython with:: pip install Cython --install-option="--no-cython-compile" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/compile/ctuple_unused_T3543.pyx new/Cython-0.29.17/tests/compile/ctuple_unused_T3543.pyx --- old/Cython-0.29.16/tests/compile/ctuple_unused_T3543.pyx 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.17/tests/compile/ctuple_unused_T3543.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -0,0 +1,9 @@ +# ticket: 3543 +# mode: compile + +# Views define unused ctuples, including (long,) +from cython cimport view + +# Implicitly generate a ctuple (long,) +obj = None +obj or (1,) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/pypy_bugs.txt new/Cython-0.29.17/tests/pypy_bugs.txt --- old/Cython-0.29.16/tests/pypy_bugs.txt 2018-09-22 16:18:56.000000000 +0200 +++ new/Cython-0.29.17/tests/pypy_bugs.txt 2020-04-26 16:37:12.000000000 +0200 @@ -11,6 +11,8 @@ yield_from_pep380 memoryview_inplace_division +run.reimport_failure + # gc issue? memoryview_in_subclasses external_ref_reassignment diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/always_allow_keywords_T295.pyx new/Cython-0.29.17/tests/run/always_allow_keywords_T295.pyx --- old/Cython-0.29.16/tests/run/always_allow_keywords_T295.pyx 2015-06-22 14:53:11.000000000 +0200 +++ new/Cython-0.29.17/tests/run/always_allow_keywords_T295.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -2,15 +2,23 @@ cimport cython +def assert_typeerror_no_keywords(func, *args, **kwds): + # Python 3.9 produces an slightly different error message + # to previous versions, so doctest isn't matching the + # traceback + try: + func(*args, **kwds) + except TypeError as e: + assert e.args[0].endswith(" takes no keyword arguments"), e.args[0] + else: + assert False, "call did not raise TypeError" + def func1(arg): """ >>> func1(None) >>> func1(*[None]) - >>> func1(arg=None) - Traceback (most recent call last): - ... - TypeError: func1() takes no keyword arguments + >>> assert_typeerror_no_keywords(func1, arg=None) """ pass @@ -19,10 +27,7 @@ """ >>> func2(None) >>> func2(*[None]) - >>> func2(arg=None) - Traceback (most recent call last): - ... - TypeError: func2() takes no keyword arguments + >>> assert_typeerror_no_keywords(func2, arg=None) """ pass @@ -39,16 +44,10 @@ """ >>> A().meth1(None) >>> A().meth1(*[None]) - >>> A().meth1(arg=None) - Traceback (most recent call last): - ... - TypeError: meth1() takes no keyword arguments + >>> assert_typeerror_no_keywords(A().meth1, arg=None) >>> A().meth2(None) >>> A().meth2(*[None]) - >>> A().meth2(arg=None) - Traceback (most recent call last): - ... - TypeError: meth2() takes no keyword arguments + >>> assert_typeerror_no_keywords(A().meth2, arg=None) >>> A().meth3(None) >>> A().meth3(*[None]) >>> A().meth3(arg=None) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/bytesmethods.pyx new/Cython-0.29.17/tests/run/bytesmethods.pyx --- old/Cython-0.29.16/tests/run/bytesmethods.pyx 2017-09-16 09:37:01.000000000 +0200 +++ new/Cython-0.29.17/tests/run/bytesmethods.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -1,5 +1,13 @@ cimport cython +cdef extern from *: + cdef Py_ssize_t PY_SSIZE_T_MIN + cdef Py_ssize_t PY_SSIZE_T_MAX + +SSIZE_T_MAX = PY_SSIZE_T_MAX +SSIZE_T_MIN = PY_SSIZE_T_MIN + + b_a = b'a' b_b = b'b' @@ -114,6 +122,14 @@ <BLANKLINE> >>> print(bytes_decode(s, -300, -500)) <BLANKLINE> + >>> print(bytes_decode(s, SSIZE_T_MIN, SSIZE_T_MIN)) + <BLANKLINE> + >>> print(bytes_decode(s, SSIZE_T_MIN, SSIZE_T_MAX)) + abaab + >>> print(bytes_decode(s, SSIZE_T_MAX, SSIZE_T_MIN)) + <BLANKLINE> + >>> print(bytes_decode(s, SSIZE_T_MAX, SSIZE_T_MAX)) + <BLANKLINE> >>> s[:'test'] # doctest: +ELLIPSIS Traceback (most recent call last): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/charptr_decode.pyx new/Cython-0.29.17/tests/run/charptr_decode.pyx --- old/Cython-0.29.16/tests/run/charptr_decode.pyx 2016-12-10 16:41:07.000000000 +0100 +++ new/Cython-0.29.17/tests/run/charptr_decode.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -1,6 +1,11 @@ cimport cython +cdef extern from *: + cdef Py_ssize_t PY_SSIZE_T_MIN + cdef Py_ssize_t PY_SSIZE_T_MAX + + ############################################################ # tests for char* slicing @@ -118,6 +123,19 @@ (cstring+1)[:].decode('UTF-8'), (cstring+1)[return1():return5()].decode('UTF-8')) [email protected]_assert_path_exists("//PythonCapiCallNode") [email protected]_fail_if_path_exists("//AttributeNode") +def slice_charptr_decode_large_bounds(): + """ + >>> print(str(slice_charptr_decode_large_bounds()).replace("u'", "'")) + ('abcABCqtp', '', '', '') + """ + return (cstring[PY_SSIZE_T_MIN:9].decode('UTF-8'), + cstring[PY_SSIZE_T_MAX:PY_SSIZE_T_MIN].decode('UTF-8'), + cstring[PY_SSIZE_T_MIN:PY_SSIZE_T_MIN].decode('UTF-8'), + cstring[PY_SSIZE_T_MAX:PY_SSIZE_T_MAX].decode('UTF-8')) + + cdef return1(): return 1 cdef return3(): return 3 cdef return4(): return 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/cpp_move.pyx new/Cython-0.29.17/tests/run/cpp_move.pyx --- old/Cython-0.29.16/tests/run/cpp_move.pyx 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.17/tests/run/cpp_move.pyx 2020-04-19 11:26:03.000000000 +0200 @@ -0,0 +1,34 @@ +# mode: run +# tag: cpp, werror, cpp11 + +from libcpp cimport nullptr +from libcpp.memory cimport shared_ptr, make_shared +from libcpp.utility cimport move +from cython.operator cimport dereference + +cdef extern from *: + """ + #include <string> + + template<typename T> const char* move_helper(T&) { return "lvalue-ref"; } + template<typename T> const char* move_helper(T&&) { return "rvalue-ref"; } + """ + const char* move_helper[T](T) + +def test_move_assignment(): + """ + >>> test_move_assignment() + """ + cdef shared_ptr[int] p1, p2 + p1 = make_shared[int](1337) + p2 = move(p1) + assert p1 == nullptr + assert dereference(p2) == 1337 + +def test_move_func_call(): + """ + >>> test_move_func_call() + """ + cdef shared_ptr[int] p + assert move_helper(p) == b'lvalue-ref' + assert move_helper(move(p)) == b'rvalue-ref' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/reimport_failure.srctree new/Cython-0.29.17/tests/run/reimport_failure.srctree --- old/Cython-0.29.16/tests/run/reimport_failure.srctree 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.17/tests/run/reimport_failure.srctree 2020-04-26 16:37:12.000000000 +0200 @@ -0,0 +1,38 @@ +# mode: run +# tag: pep489 + +""" +PYTHON setup.py build_ext -i +PYTHON tester.py +""" + +######## setup.py ######## + +from Cython.Build.Dependencies import cythonize +from distutils.core import setup + +setup( + ext_modules = cythonize("*.pyx"), +) + + +######## failure.pyx ######## + +if globals(): # runtime True to confuse dead code removal + raise ImportError + +cdef class C: + cdef int a + + +######## tester.py ######## + +try: + try: + import failure # 1 + except ImportError: + import failure # 2 +except ImportError: + pass +else: + raise RuntimeError("ImportError was not raised on second import!") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/tracebacks.pyx new/Cython-0.29.17/tests/run/tracebacks.pyx --- old/Cython-0.29.16/tests/run/tracebacks.pyx 2017-09-16 09:37:01.000000000 +0200 +++ new/Cython-0.29.17/tests/run/tracebacks.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -1,4 +1,4 @@ -import traceback +# tag: traceback def foo1(): foo2() @@ -21,6 +21,7 @@ try: foo1() except: + import traceback tb_string = traceback.format_exc() expected = ( 'tracebacks.pyx', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.16/tests/run/unicode_slicing.pyx new/Cython-0.29.17/tests/run/unicode_slicing.pyx --- old/Cython-0.29.16/tests/run/unicode_slicing.pyx 2015-06-22 14:53:11.000000000 +0200 +++ new/Cython-0.29.17/tests/run/unicode_slicing.pyx 2020-04-26 16:37:12.000000000 +0200 @@ -151,30 +151,52 @@ >>> slice_none_none(None, 2, 4) Traceback (most recent call last): TypeError: 'NoneType' object is not subscriptable + + >>> slice_start_end(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + <BLANKLINE> + >>> slice_start(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + <BLANKLINE> + >>> slice_end(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + abcdef + >>> slice_all(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + abcdef + >>> slice_start_none(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + <BLANKLINE> + >>> slice_none_end(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + abcdef + >>> slice_none_none(u'abcdef', SSIZE_T_MAX, SSIZE_T_MIN) + abcdef """ +cdef extern from *: + cdef Py_ssize_t PY_SSIZE_T_MIN + cdef Py_ssize_t PY_SSIZE_T_MAX + +SSIZE_T_MAX = PY_SSIZE_T_MAX +SSIZE_T_MIN = PY_SSIZE_T_MIN + import sys if sys.version_info[0] >= 3: __doc__ = __doc__.replace(u"(u'", u"('").replace(u" u'", u" '") -def slice_start_end(unicode s, int i, int j): +def slice_start_end(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[i:j]) -def slice_start(unicode s, int i, int j): +def slice_start(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[i:]) -def slice_end(unicode s, int i, int j): +def slice_end(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[:i]) -def slice_all(unicode s, int i, int j): +def slice_all(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[:]) -def slice_start_none(unicode s, int i, int j): +def slice_start_none(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[i:None]) -def slice_none_end(unicode s, int i, int j): +def slice_none_end(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[None:i]) -def slice_none_none(unicode s, int i, int j): +def slice_none_none(unicode s, Py_ssize_t i, Py_ssize_t j): print(s[None:None])
