Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-102721: Improve coverage of_collections_abc._CallableGenericAlias#102722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AlexWaygood merged 2 commits intopython:mainfromsobolevn:issue-102721
Mar 16, 2023

Conversation

sobolevn
Copy link
Member

@sobolevnsobolevn commentedMar 15, 2023
edited by AlexWaygood
Loading

Two main changes:

  1. Morepickle tests with different callables
  2. Passing things like0 is not allowed, so I think testing this behaviour won't hurt. The test is quite simple

All tests work for bothtyping.Callable and_collections_abc.Callable.

I also went ahead and remove this suspiciousif from#102681 (comment)

Moreover, all tests pass without it.
I cannot find any examples where it is needed. Please, prove me wrong.

CC@AlexWaygood

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Comment on lines -487 to -492
# A special case in PEP 612 where if X = Callable[P, int],
# then X[int, str] == X[[int, str]].
if (len(self.__parameters__) == 1
and _is_param_expr(self.__parameters__[0])
and item and not _is_param_expr(item[0])):
item = (item,)
Copy link
Member

@AlexWaygoodAlexWaygoodMar 15, 2023
edited
Loading

Choose a reason for hiding this comment

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

This makes me slightly nervous, but I can't find any changes in behaviour from removing this code.

@Fidget-Spinner and@serhiy-storchaka, can either of you think of anything bad that could happen if we remove this code? The whole test suite passes with it removed.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, me too. Let's wait for others to comment.

AlexWaygood reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

It makes me nervous too. In case you're looking for an example that triggers this path, here's one:

fromtypingimportParamSpecP=ParamSpec("P")fromcollections.abcimportCallableC=Callable[[P],int]print(C[str])

However I agree that if I just comment this out, the output is the same. It's possible that@serhiy-storchaka fixed the issue in the C code (thesuper() method) -- the code here is from Aug 4th, 2021, while he touched_Py_subs_parameters on May 8th, 2022.

AlexWaygood reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I found examples that triggered this code path, but for all of the examples I found, I couldn't find any differences in behaviour with this code deleted (repr,__args__,__parameters__, equality)

Copy link
Member

Choose a reason for hiding this comment

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

Someone could trace through the C code that gets called and see if it does the right thing.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Looks like_unpack_args C function which was added in May now handles this case:https://github.com/python/cpython/blame/2dc94634b50f0e5e207787e5ac1d56c68b22c3ae/Objects/genericaliasobject.c#L361

It unpacks nested tuples to a flat format, so - this code is not needed anymore.

Copy link
Member

Choose a reason for hiding this comment

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

I don't suppose the pure-Python code could be useful for PyPy, could it? (Don't see how it could, just throwing that out there)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Sorry, the only other iterperter I worked on isRustPython.

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

Looks good to me other than my nervousness abouthttps://github.com/python/cpython/pull/102722/files#r1137196475

@rhettingerrhettinger removed their request for reviewMarch 15, 2023 15:30
Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

Don’t worry about PyPy.

AlexWaygood reacted with thumbs up emoji
@AlexWaygoodAlexWaygood merged commitfbe82fd intopython:mainMar 16, 2023
@AlexWaygood
Copy link
Member

Thanks@sobolevn! I'd like to backport the coverage improvements, but not the code changes.

@sobolevn
Copy link
MemberAuthor

I'd like to backport the coverage improvements, but not the code changes.

Do you want me to do that? Or do you want to do that yourself?

I am fine with both :)

@AlexWaygood
Copy link
Member

Would be great if you could take care of it, thanks!

sobolevn reacted with thumbs up emoji

@sobolevn
Copy link
MemberAuthor

Scheduled for tomorrow then :)

AlexWaygood reacted with heart emoji

carljm added a commit to carljm/cpython that referenced this pull requestMar 17, 2023
* main: (34 commits)pythongh-102701: Fix overflow in dictobject.c (pythonGH-102750)pythonGH-78530: add support for generators in `asyncio.wait` (python#102761)  Increase stack reserve size for Windows debug builds to avoid test crashes (pythonGH-102764)pythongh-102755: Add PyErr_DisplayException(exc) (python#102756)  Fix outdated note about 'int' rounding or truncating (python#102736)pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (python#102760)pythongh-99726: Improves correctness of stat results for Windows, and uses faster API when available (pythonGH-102149)pythongh-102192: remove redundant exception fields from ssl module socket (python#102466)pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (python#102743)pythongh-102737: Un-ignore ceval.c in the CI globals check (pythongh-102745)pythonGH-102748: remove legacy support for generator based coroutines from `asyncio.iscoroutine` (python#102749)pythongh-102721: Improve coverage of `_collections_abc._CallableGenericAlias` (python#102722)pythonGH-102653: Make recipe docstring show the correct distribution (python#102742)  Add comments to `{typing,_collections_abc}._type_repr` about each other (python#102752)pythongh-102594: PyErr_SetObject adds note to exception raised on normalization error (python#102675)pythongh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (python#94468)pythonGH-100112:  avoid using iterable coroutines in asyncio internally (python#100128)pythongh-102690: Use Edge as fallback in webbrowser instead of IE (python#102691)pythongh-102660: Fix Refleaks in import.c (python#102744)pythongh-102738: remove from cases generator the code related to register instructions (python#102739)  ...
miss-islington pushed a commit that referenced this pull requestMar 17, 2023
…ricAlias` (GH-102788)This is a backport of#102722 without the `typing.py` changes.Automerge-Triggered-By: GH:AlexWaygood
miss-islington pushed a commit that referenced this pull requestMar 17, 2023
…ricAlias` (GH-102790)This is a manual backport of#102722 but without `typing.py` changes and without `TypeVarTuple` case, because it was added in 3.11Automerge-Triggered-By: GH:AlexWaygood
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull requestMar 27, 2023
…icAlias` (python#102722)Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
warsaw pushed a commit to warsaw/cpython that referenced this pull requestApr 11, 2023
…icAlias` (python#102722)Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

@gvanrossumgvanrossumgvanrossum approved these changes

@Fidget-SpinnerFidget-SpinnerAwaiting requested review from Fidget-Spinner

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstraJelleZijlstra is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@sobolevn@AlexWaygood@gvanrossum@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp