Skip to content

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

Merged
serhiy-storchaka merged 5 commits intopython:mainfrom
sunmy2019:gh-146615-5
Mar 31, 2026
Merged

gh-146615: Fix error message in method_get for invalid type argument#146634
serhiy-storchaka merged 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.

@serhiy-storchaka
Copy link
Copy Markdown
Member

LGTM. 👍

@serhiy-storchaka serhiy-storchaka merged commit 72d29ea into python:main Mar 31, 2026
57 checks passed
@miss-islington-app
Copy link
Copy Markdown

Thanks @sunmy2019 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Mar 31, 2026

GH-146647 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Mar 31, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 31, 2026
…ith invalid type argument (pythonGH-146634)

(cherry picked from commit 72d29ea363f1515115753653aeca735a1a817a7f)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 31, 2026
…ith invalid type argument (pythonGH-146634)

(cherry picked from commit 72d29ea363f1515115753653aeca735a1a817a7f)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Mar 31, 2026

GH-146648 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 31, 2026
serhiy-storchaka pushed a commit that referenced this pull request Mar 31, 2026
…with invalid type argument (GH-146634) (GH-146647)

(cherry picked from commit 72d29ea)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this pull request Mar 31, 2026
…with invalid type argument (GH-146634) (GH-146648)

(cherry picked from commit 72d29ea)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
maurycy added a commit to maurycy/cpython that referenced this pull request Mar 31, 2026
* main:
  pythongh-145458: use `self.skip_idle` consistently in the tachyon profiler (python#145459)
  pythongh-146615: Fix format specifiers in Objects/ directory (pythonGH-146620)
  pythongh-146615: Fix format specifiers in Python/ directory (pythonGH-146619)
  pythongh-146615: Fix format specifiers in test cextensions (pythonGH-146618)
  pythongh-146615: Fix format specifiers in extension modules (pythonGH-146617)
  pythongh-146615: Fix crash in __get__() for METH_METHOD descriptors with invalid type argument (pythonGH-146634)
  pythongh-146376: Reduce timeout in Emscripten GHA workflow (python#146378)
  pythongh-146442: Fix various bugs in compiler pipeline (python#146443)
  pythongh-146238: Support half-floats in the array module (python#146242)
  pythongh-145056: Add support for merging collections.UserDict and frozendict (pythonGH-146465)
  pythongh-145056: Fix merging of collections.OrderedDict and frozendict (pythonGH-146466)
  pythongh-139633: Run netrc file permission check only once per parse (pythonGH-139634)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants