Skip to content

inspect: Fix isgenerator logic. #998

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2025

Conversation

dpgeorge
Copy link
Member

Fix the isgenerator() logic.

Also optimise both isgenerator() and isgeneratorfunction() so they use the same lambda, and don't have to create it each time they are called.

And add some basic unit tests for this package.

Fixes issue #997.

@dpgeorge dpgeorge linked an issue Apr 11, 2025 that may be closed by this pull request
@smurfix
Copy link
Contributor

smurfix commented Apr 13, 2025

Looks sensible, thanks.

@smurfix
Copy link
Contributor

smurfix commented Apr 13, 2025

While you're at it, might you be persuaded to add

iscoroutinefunction = isgeneratorfunction
iscoroutine = isgenerator

as per micropython/micropython#11526 ?

Also optimise both `isgenerator()` and `isgeneratorfunction()` so they use
the same lambda, and don't have to create it each time they are called.

Fixes issue micropython#997.

Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
@dpgeorge dpgeorge force-pushed the inspect-fix-isgenerator branch from afb620b to 5b496e9 Compare April 14, 2025 00:26
@dpgeorge
Copy link
Member Author

While you're at it, might you be persuaded to add

Good idea, now done. See what you think.

@dpgeorge dpgeorge merged commit 5b496e9 into micropython:master Apr 14, 2025
4 checks passed
@dpgeorge dpgeorge deleted the inspect-fix-isgenerator branch April 14, 2025 02:29
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.

inspect.isgenerator is broken
2 participants