Update to 0.29.21

This commit is contained in:
serge-sans-paille 2020-12-06 12:58:23 +00:00
commit 24b4ad257e
5 changed files with 7 additions and 214 deletions

1
.gitignore vendored
View file

@ -44,3 +44,4 @@ Cython-0.12.1.tar.gz
/Cython-0.29.16.tar.gz
/Cython-0.29.17.tar.gz
/Cython-0.29.19.tar.gz
/Cython-0.29.21.tar.gz

View file

@ -4,27 +4,15 @@
%bcond_without tests
Name: Cython
Version: 0.29.19
Version: 0.29.21
%global upver %{version_no_tilde %{nil}}
Release: 2%{?dist}
Release: 1%{?dist}
Summary: Language for writing Python extension modules
License: ASL 2.0
URL: http://www.cython.org
Source: https://github.com/cython/cython/archive/%{upver}/%{srcname}-%{version}.tar.gz
# Backported from upstream, fixes an undefined behavior and allows clang interoperability
Patch2705: f639e6d435cb240c5c21afe91a71915c4af23b7c.patch
# Partially work around issues with class and static methods
# See https://bugzilla.redhat.com/show_bug.cgi?id=1788506
# Mostly backported from upstream: https://github.com/cython/cython/pull/3106
# This also:
# - Removes staticmethod optimizations for normal functions
# - Removes failing test for staticmethod fused functions, which still fail
# See also: https://github.com/cython/cython/issues/3614
Patch3106: class-static-method-workaround.patch
BuildRequires: gcc
%if %{with tests}
BuildRequires: gcc-c++
@ -121,6 +109,9 @@ cp -p cython-mode-init.el cython-mode-init.elc %{buildroot}%{_emacs_sitestartdir
%{_emacs_sitestartdir}/cython*.el*
%changelog
* Fri Dec 4 2020 sguelton@redhat.com - 0.29.21-1
- Update to 0.29.21
* Wed May 27 2020 sguelton@redhat.com - 0.29.19-2
- Backport f639e6d435cb240c, see [RHELPLAN-41401]

View file

@ -1,139 +0,0 @@
diff -U3 -r cython-0.29.17.orig/Cython/Compiler/ExprNodes.py cython-0.29.17/Cython/Compiler/ExprNodes.py
--- cython-0.29.17.orig/Cython/Compiler/ExprNodes.py 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/Cython/Compiler/ExprNodes.py 2020-05-15 17:44:55.157172257 +0200
@@ -2295,8 +2295,10 @@
setter = 'PyDict_SetItem'
namespace = Naming.moddict_cname
elif entry.is_pyclass_attr:
- code.globalstate.use_utility_code(UtilityCode.load_cached("SetNameInClass", "ObjectHandling.c"))
- setter = '__Pyx_SetNameInClass'
+ # Special-case setting __new__
+ n = "SetNewInClass" if self.name == "__new__" else "SetNameInClass"
+ code.globalstate.use_utility_code(UtilityCode.load_cached(n, "ObjectHandling.c"))
+ setter = '__Pyx_' + n
else:
assert False, repr(entry)
code.put_error_if_neg(
diff -U3 -r cython-0.29.17.orig/Cython/Compiler/Nodes.py cython-0.29.17/Cython/Compiler/Nodes.py
--- cython-0.29.17.orig/Cython/Compiler/Nodes.py 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/Cython/Compiler/Nodes.py 2020-05-15 17:44:55.159172253 +0200
@@ -2872,7 +2872,6 @@
func = decorator.decorator
if func.is_name:
self.is_classmethod |= func.name == 'classmethod'
- self.is_staticmethod |= func.name == 'staticmethod'
if self.is_classmethod and env.lookup_here('classmethod'):
# classmethod() was overridden - not much we can do here ...
diff -U3 -r cython-0.29.17.orig/Cython/Utility/CythonFunction.c cython-0.29.17/Cython/Utility/CythonFunction.c
--- cython-0.29.17.orig/Cython/Utility/CythonFunction.c 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/Cython/Utility/CythonFunction.c 2020-05-15 17:44:55.160172251 +0200
@@ -548,21 +548,6 @@
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
-
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
-
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
-
- if (obj == Py_None)
- obj = NULL;
return __Pyx_PyMethod_New(func, obj, type);
}
diff -U3 -r cython-0.29.17.orig/Cython/Utility/ObjectHandling.c cython-0.29.17/Cython/Utility/ObjectHandling.c
--- cython-0.29.17.orig/Cython/Utility/ObjectHandling.c 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/Cython/Utility/ObjectHandling.c 2020-05-15 17:44:55.160172251 +0200
@@ -1163,6 +1163,30 @@
#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
#endif
+/////////////// SetNewInClass.proto ///////////////
+
+static int __Pyx_SetNewInClass(PyObject *ns, PyObject *name, PyObject *value);
+
+/////////////// SetNewInClass ///////////////
+//@requires: SetNameInClass
+
+// Special-case setting __new__: if it's a Cython function, wrap it in a
+// staticmethod. This is similar to what Python does for a Python function
+// called __new__.
+static int __Pyx_SetNewInClass(PyObject *ns, PyObject *name, PyObject *value) {
+#ifdef __Pyx_CyFunction_USED
+ int ret;
+ if (__Pyx_CyFunction_Check(value)) {
+ PyObject *staticnew = PyStaticMethod_New(value);
+ if (unlikely(!staticnew)) return -1;
+ ret = __Pyx_SetNameInClass(ns, name, staticnew);
+ Py_DECREF(staticnew);
+ return ret;
+ }
+#endif
+ return __Pyx_SetNameInClass(ns, name, value);
+}
+
/////////////// GetModuleGlobalName.proto ///////////////
//@requires: PyDictVersioning
Only in cython-0.29.17.orig: cython-0.29.17
diff -U3 -r cython-0.29.17.orig/tests/run/cyfunction.pyx cython-0.29.17/tests/run/cyfunction.pyx
--- cython-0.29.17.orig/tests/run/cyfunction.pyx 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/tests/run/cyfunction.pyx 2020-05-15 17:44:55.160172251 +0200
@@ -376,6 +376,18 @@
def meth(self): pass
+class TestStaticmethod(object):
+ """
+ >>> x = TestStaticmethod()
+ >>> x.staticmeth(42)
+ 42
+ >>> x.staticmeth.__get__(42)()
+ 42
+ """
+ @staticmethod
+ def staticmeth(arg): return arg
+
+
cdef class TestOptimisedBuiltinMethod:
"""
>>> obj = TestOptimisedBuiltinMethod()
diff -U3 -r cython-0.29.17.orig/tests/run/fused_def.pyx cython-0.29.17/tests/run/fused_def.pyx
--- cython-0.29.17.orig/tests/run/fused_def.pyx 2020-04-26 13:48:48.000000000 +0200
+++ cython-0.29.17/tests/run/fused_def.pyx 2020-05-15 18:03:39.436752174 +0200
@@ -268,14 +268,6 @@
def test_fused_def_super():
"""
>>> test_fused_def_super()
- long 10
- long 11
- long 11
- long 12
- short 12
- long 13
- short 13
- long 14
<class 'fused_def.SubClass'> long 14
<class 'fused_def.SubClass'> long 15
<class 'fused_def.SubClass'> long 15
@@ -296,11 +288,6 @@
obj = SubClass()
cls = SubClass
- obj.mystaticmethod(obj, 10)
- cls.mystaticmethod(obj, 11)
- obj.mystaticmethod[cy.short](obj, 12)
- cls.mystaticmethod[cy.short](obj, 13)
-
obj.myclassmethod(14)
cls.myclassmethod(15)
obj.myclassmethod[cy.short](16)

View file

@ -1,60 +0,0 @@
From f639e6d435cb240c5c21afe91a71915c4af23b7c Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Tue, 26 May 2020 18:27:22 +0200
Subject: [PATCH] Fix overflow handling for abs() calls on signed integer types
(GH-3634)
Fixes #1911
---
Cython/Compiler/ExprNodes.py | 19 ++++++++++++-------
tests/run/builtin_abs.pyx | 1 +
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 48c7f721c7..25e84fd915 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -5934,6 +5934,17 @@ def generate_evaluation_code(self, code):
if function.is_name or function.is_attribute:
code.globalstate.use_entry_utility_code(function.entry)
+ abs_function_cnames = ('abs', 'labs', '__Pyx_abs_longlong')
+ is_signed_int = self.type.is_int and self.type.signed
+ if self.overflowcheck and is_signed_int and function.result() in abs_function_cnames:
+ code.globalstate.use_utility_code(UtilityCode.load_cached("Common", "Overflow.c"))
+ code.putln('if (unlikely(%s == __PYX_MIN(%s))) {\
+ PyErr_SetString(PyExc_OverflowError,\
+ "Trying to take the absolute value of the most negative integer is not defined."); %s; }' % (
+ self.args[0].result(),
+ self.args[0].type.empty_declaration_code(),
+ code.error_goto(self.pos)))
+
if not function.type.is_pyobject or len(self.arg_tuple.args) > 1 or (
self.arg_tuple.args and self.arg_tuple.is_literal):
super(SimpleCallNode, self).generate_evaluation_code(code)
@@ -6036,13 +6047,7 @@ def generate_result_code(self, code):
self.result() if self.type.is_pyobject else None,
func_type.exception_value, self.nogil)
else:
- if (self.overflowcheck
- and self.type.is_int
- and self.type.signed
- and self.function.result() in ('abs', 'labs', '__Pyx_abs_longlong')):
- goto_error = 'if (unlikely(%s < 0)) { PyErr_SetString(PyExc_OverflowError, "value too large"); %s; }' % (
- self.result(), code.error_goto(self.pos))
- elif exc_checks:
+ if exc_checks:
goto_error = code.error_goto_if(" && ".join(exc_checks), self.pos)
else:
goto_error = ""
diff --git a/tests/run/builtin_abs.pyx b/tests/run/builtin_abs.pyx
index 21bea7df20..5b35eb886a 100644
--- a/tests/run/builtin_abs.pyx
+++ b/tests/run/builtin_abs.pyx
@@ -1,5 +1,6 @@
# mode: run
# ticket: 698
+# distutils: extra_compile_args=-fwrapv
cdef extern from *:
int INT_MAX

View file

@ -1 +1 @@
SHA512 (Cython-0.29.19.tar.gz) = 402f95f82099db0ae99ca2f849a9aef97558c9c6be62d3b3c66c346ecc94efbbe824ffc77f3cc6dd1d7054a2fb0332b10fe855ca1b054095f2df2ee297fd96a7
SHA512 (Cython-0.29.21.tar.gz) = 2c0c3e3fff07106eb98862f71cd5dec9ff29460cf9b9e4de74537ca5e033f7523989beb5fbdc14723beaf94a535976f75c803e791b87e017961d9694b8c37679