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