Skip to content

Commit 6666a1a

Browse files
committed
Revert "fill __module__ attribute for built-in classmethods too"
This reverts commit c4dec10.
1 parent b3fbb8c commit 6666a1a

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

Lib/test/test_funcattrs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ def test_builtin__module__(self):
474474
self.assertEqual(decimal.Decimal.exp.__objclass__.__module__, 'decimal')
475475

476476
# builtin classmethod:
477-
self.assertEqual(int.from_bytes.__module__, 'builtins')
477+
self.assertEqual(int.from_bytes.__module__, None)
478478
self.assertEqual(int.from_bytes.__self__.__module__, 'builtins')
479-
self.assertEqual(decimal.Decimal.from_float.__module__, 'decimal')
479+
self.assertEqual(decimal.Decimal.from_float.__module__, None)
480480
self.assertEqual(decimal.Decimal.from_float.__self__.__module__, 'decimal')
481481

482482
# builtin staticmethod:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Setup ``__module__`` attribute for built-in class/static methods. Patch by
2-
Sergey B Kirpichev.
1+
Setup ``__module__`` attribute for built-in static methods. Patch by Sergey
2+
B Kirpichev.

Objects/descrobject.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ classmethod_get(PyObject *self, PyObject *obj, PyObject *type)
131131
if (descr->d_method->ml_flags & METH_METHOD) {
132132
cls = descr->d_common.d_type;
133133
}
134-
PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__));
135-
PyErr_Clear();
136-
PyObject *result = PyCMethod_New(descr->d_method, type, mod, cls);
137-
Py_XDECREF(mod);
138-
return result;
134+
return PyCMethod_New(descr->d_method, type, NULL, cls);
139135
}
140136

141137
static PyObject *

0 commit comments

Comments
 (0)