Skip to content

gh-146615: Fix error message in method_get for invalid type argument#146634

Open
sunmy2019 wants to merge 5 commits intopython:mainfrom
sunmy2019:gh-146615-5
Open

gh-146615: Fix error message in method_get for invalid type argument#146634
sunmy2019 wants to merge 5 commits intopython:mainfrom
sunmy2019:gh-146615-5

Conversation

@sunmy2019
Copy link
Copy Markdown
Member

@sunmy2019 sunmy2019 commented Mar 30, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Please add a test and a NEWS entry.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 30, 2026
@sunmy2019 sunmy2019 marked this pull request as ready for review March 30, 2026 18:01
# METH_METHOD|METH_FASTCALL|METH_KEYWORDS is the only flag combination
# that enters the affected branch in method_get().

import xxlimited
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It could be tested without the use of the optional xxlimited module. For example:

array.array.extend.__get__(array.array('I'), 'not_a_type')

Of course, using METH_METHOD|METH_FASTCALL|METH_KEYWORDS in the implementation of array.array.extend is CPython specific, so you can try several other classes and methods in hope that they are implemented in such way. If none of them raises a TypeError, then skip the test (skipTest()). Or maybe mark the test CPython-only?

Copy link
Copy Markdown
Member Author

@sunmy2019 sunmy2019 Mar 30, 2026

Choose a reason for hiding this comment

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

mark the test CPython-only?

I think this is reasonable. This problem only occurs in C modules. It cannot trigger in pure Python code.

I checked

array.array.extend.__get__(array.array('I'), 'not_a_type')

will not raise error in Pypy.

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

Labels

awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants