Skip to content

Conversation

@methane
Copy link
Member

@methane methane commented Mar 26, 2019

PyErr_Format(PyExc_TypeError,
"descriptor '%V' requires a type "
"but received a '%.100s'",
"descriptor '%V' requires a subtype of '%.100s' "
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure that subtype of '%.100s' is better than just type. It contains more information, but I think that this information is redundant at that moment and distracts from the true error -- passing an instance instead of a type.

Maybe just remove PyDescr_TYPE(descr)->tp_name?

spam_cm()
with self.assertRaises(TypeError):
self.assertEqual(
cm.exception.args[0],
Copy link
Member

Choose a reason for hiding this comment

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

It may be better to test str(cm.exception) instead of cm.exception.args[0]. Just for the case if error messages be generated dynamically in the future.

@miss-islington
Copy link
Contributor

@methane: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 871309c into python:master Mar 26, 2019
@miss-islington
Copy link
Contributor

Thanks @methane for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-12557 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 26, 2019
miss-islington added a commit that referenced this pull request Mar 26, 2019
…12556)

https://bugs.python.org/issue36433
(cherry picked from commit 871309c)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
@methane methane deleted the classmethod_descr branch April 28, 2025 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants