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