[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Okay, it's fixed.  Thanks for the report.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 34be48450f03b121be10a9f8e8989603478f0469 by Miss Islington (bot) 
in branch '3.9':
bpo-43917: Fix pure python equivalent for classmethod (GH-25544) (GH-25546)
https://github.com/python/cpython/commit/34be48450f03b121be10a9f8e8989603478f0469


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +24270
pull_request: https://github.com/python/cpython/pull/25546

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 14092b5a4ae4caf1c77f685450016a0d1ad0bd6c by Raymond Hettinger in 
branch 'master':
bpo-43917: Fix pure python equivalent for classmethod (GH-25544)
https://github.com/python/cpython/commit/14092b5a4ae4caf1c77f685450016a0d1ad0bd6c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +24268
pull_request: https://github.com/python/cpython/pull/25544

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It looks like it should be:

if hasattr(type(self.f), "__get__"):


Here's the relevant C code:

static PyObject *
cm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
classmethod *cm = (classmethod *)self;

if (cm->cm_callable == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"uninitialized classmethod object");
return NULL;
}
if (type == NULL)
type = (PyObject *)(Py_TYPE(obj));
if (Py_TYPE(cm->cm_callable)->tp_descr_get != NULL) {
return Py_TYPE(cm->cm_callable)->tp_descr_get(cm->cm_callable, type,
  NULL);
}
return PyMethod_New(cm->cm_callable, type);
}

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 3.0 -> 4.0
pull_requests: +24262
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25541

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee: docs@python -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43917] An error in classmethod example in the documentation of descriptor

2021-04-22 Thread Egor


New submission from Egor :

In this section https://docs.python.org/3/howto/descriptor.html#class-methods 
in the example of python implementation of ClassMethod inside __get__ method I 
think that we should check hasattr(self.f, "__get__") instead of hasattr(obj, 
"__get__").

--
assignee: docs@python
components: Documentation
messages: 391638
nosy: docs@python, rhettinger, titanolodon
priority: normal
severity: normal
status: open
title: An error in classmethod example in the documentation of descriptor
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com