GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — typing tests: remove some unnecessary uses of `exec()` by AlexWaygood · Pull Request #119005 · python/cpython

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented May 13, 2024

Copy link
Copy Markdown
Member

This is a forward-port of python/typing_extensions#219

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexWaygood
typing tests: remove some unnecessary uses of exec()
168d87b
@AlexWaygood
AlexWaygood requested a review from JelleZijlstra as a code owner May 13, 2024 17:02
@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting core review labels May 13, 2024
@AlexWaygood AlexWaygood added skip issue skip news needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes awaiting core review topic-typing and removed awaiting core review labels May 13, 2024
JelleZijlstra
JelleZijlstra reviewed May 13, 2024
View reviewed changes
Comment thread Lib/test/test_typing.py Outdated
exec('async def g(): yield 0', globals(), ns)
g = ns['g']
async def g(): yield 0
g = g()

@JelleZijlstra JelleZijlstra May 13, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In the old code here g was the function, now it's the coroutine returned from the function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood May 13, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

good catch. Sorry, that was sloppy.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood May 13, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Although on second thought... doesn't it make more sense to test the coroutine returned from the function here? I think the test might be buggy as-written.

It passes regardless, and this PR wasn't meant to make any semantic changes to the tests, so I'm happy to leave it as-is for now (I pushed 6f25644), but it looks odd to me

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra May 13, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah, it's odd that the passes both with and without the g(). Might be worth looking into whether we can make the test more effective.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood May 13, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It makes sense that it passes both with and without the g(), because g is only used to check that the [coroutine-function or coroutine] is not an instance of the custom AsyncGenerator subclass here:

cpython/Lib/test/test_typing.py

Lines 7459 to 7460 in 7d7eec5

self.assertNotIsInstance(type(g), G)
self.assertNotIsInstance(g, G)

And of course, it is indeed true that neither a coroutine nor a coroutine function will be an instance of the custom AsyncGenerator subclass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexWaygood
address review
6f25644
@JelleZijlstra
JelleZijlstra merged commit a9328e2 into python:main May 14, 2024
@bedevere-app bedevere-app Bot removed the awaiting core review label May 14, 2024
@miss-islington-app

miss-islington-app Bot commented May 14, 2024

Copy link
Copy Markdown

Thanks @AlexWaygood for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 14, 2024
@AlexWaygood @miss-islington
typing tests: remove some unnecessary uses of exec() (pythonGH-119005)
c6a52f0
(cherry picked from commit a9328e2)

Co-authored-by: Alex Waygood <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 14, 2024
@AlexWaygood @miss-islington
typing tests: remove some unnecessary uses of exec() (pythonGH-119005)
1904f98
(cherry picked from commit a9328e2)

Co-authored-by: Alex Waygood <[email protected]>
@bedevere-app

bedevere-app Bot commented May 14, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 14, 2024
@bedevere-app

bedevere-app Bot commented May 14, 2024

Copy link
Copy Markdown

GH-119039 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 14, 2024
@AlexWaygood
AlexWaygood deleted the typing-tests-exec branch May 14, 2024 14:16
JelleZijlstra pushed a commit that referenced this pull request May 14, 2024
@miss-islington @AlexWaygood
[3.13] typing tests: remove some unnecessary uses of exec() (GH-119005
041cc2a
) (#119038)


(cherry picked from commit a9328e2)

Co-authored-by: Alex Waygood <[email protected]>
JelleZijlstra pushed a commit that referenced this pull request May 14, 2024
@miss-islington @AlexWaygood
[3.12] typing tests: remove some unnecessary uses of exec() (GH-119005
4695f1a
) (#119039)


(cherry picked from commit a9328e2)

Co-authored-by: Alex Waygood <[email protected]>
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@AlexWaygood @estyxx
typing tests: remove some unnecessary uses of exec() (python#119005)
91f74e3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip issue skip news tests Tests in the Lib/test dir topic-typing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@AlexWaygood @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.