classification
Title: Unhelpful error message in classmethoddescr_call()
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: inada.naoki, jdemeyer, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-03-26 08:11 by inada.naoki, last changed 2019-03-27 09:55 by inada.naoki. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12556 merged inada.naoki, 2019-03-26 08:31
PR 12557 merged miss-islington, 2019-03-26 09:26
Messages (6)
msg338860 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2019-03-26 08:11
>>> desc = dict.__dict__['fromkeys']
>>> desc(int, [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: descriptor 'fromkeys' requires a subtype of 'dict' but received 'type

`'type` should be `'int'`.
msg338861 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-26 08:19
More confusing error message:

>>> desc(1, [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: descriptor 'fromkeys' requires a type but received a 'dict'
msg338866 - (view) Author: miss-islington (miss-islington) Date: 2019-03-26 09:26
New changeset 871309c775fd4d72048bfaa31affd54f9934f7dd by Miss Islington (bot) (Inada Naoki) in branch 'master':
bpo-36433: fix confusing error messages in classmethoddescr_call (GH-12556)
https://github.com/python/cpython/commit/871309c775fd4d72048bfaa31affd54f9934f7dd
msg338869 - (view) Author: miss-islington (miss-islington) Date: 2019-03-26 09:47
New changeset 03440850e7266aa7fd531c7f281a3fdcf17f90a4 by Miss Islington (bot) in branch '3.7':
bpo-36433: fix confusing error messages in classmethoddescr_call (GH-12556)
https://github.com/python/cpython/commit/03440850e7266aa7fd531c7f281a3fdcf17f90a4
msg338947 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-03-27 09:52
I am curious, how did you find out about this bug? Do you have a concrete use case for directly calling an instance of classmethod_descriptor? Typically, one would write dict.fromkeys(...) instead of dict.__dict__['fromkeys'](dict, ...).
msg338948 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2019-03-27 09:55
See https://github.com/python/cpython/pull/11930

I found this while I wrote tests about error messages.
History
Date User Action Args
2019-03-27 09:55:02inada.naokisetmessages: + msg338948
2019-03-27 09:52:29jdemeyersetnosy: + jdemeyer
messages: + msg338947
2019-03-26 09:50:45inada.naokisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-03-26 09:47:10miss-islingtonsetmessages: + msg338869
2019-03-26 09:26:48miss-islingtonsetpull_requests: + pull_request12503
2019-03-26 09:26:35miss-islingtonsetnosy: + miss-islington
messages: + msg338866
2019-03-26 08:31:46inada.naokisetkeywords: + patch
stage: patch review
pull_requests: + pull_request12502
2019-03-26 08:19:54serhiy.storchakasetmessages: + msg338861
2019-03-26 08:18:38serhiy.storchakasetnosy: + serhiy.storchaka
2019-03-26 08:11:55inada.naokicreate