Skip to content

Conversation

@Aniketsy
Copy link
Contributor

@StanFromIreland
Copy link
Member

You need to update your branch to fix the CI, it is currently incompatible.

cm->cm_callable = Py_NewRef(Py_None);
cm->cm_dict = NULL;
return (PyObject *)cm;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move cm_new() before PyClassMethod_Type, so you don't need to declare it in advance (remove forward declaration line 1558).

sm->sm_callable = Py_NewRef(Py_None);
sm->sm_dict = NULL;
return (PyObject *)sm;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move sm_new() before PyStaticMethod_Type.

classmethod *cm = (classmethod *)PyType_GenericAlloc(type, 0);
if (cm == NULL)
return NULL;
cm->cm_callable = Py_NewRef(Py_None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None is immortal so you can just write:

Suggested change
cm->cm_callable = Py_NewRef(Py_None);
cm->cm_callable = Py_None;

Same remark in sm_new().

Comment on lines +1649 to +1650
if (cm == NULL)
return NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP 7 coding style:

Suggested change
if (cm == NULL)
return NULL;
if (cm == NULL) {
return NULL;
}

Same remark in sm_new().

sm.__init__(None)
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)

def test_staticmethod_new_none_repr(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_staticmethod_new_none_repr(self):
def test_staticmethod_new(self):


def test_staticmethod_new_none_repr(self):
sm = staticmethod.__new__(staticmethod, None)
self.assertIsInstance(repr(sm), str)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIsInstance(repr(sm), str)
self.assertEqual(repr(sm), '<staticmethod(None)>')


def test_classmethod_new_none_repr(self):
cm = classmethod.__new__(classmethod, None)
self.assertIsInstance(repr(cm), str)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIsInstance(repr(cm), str)
self.assertEqual(repr(cm), '<classmethod(None)>')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants