Skip to content

extmod/uasyncio: Fix syntax of generator functions #10190

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 1 commit into from
Dec 14, 2022

Conversation

damz
Copy link
Contributor

@damz damz commented Dec 8, 2022

What?

Fix the syntax of generator functions in the uasyncio package:

  • await is only valid in an async function
  • async functions that use yield are actually async generators (a construct not supported by the compiler right now)

Why?

The compiler is not picky right now, but these are actually all syntax errors.

@damz damz force-pushed the pr/uasyncio-generator branch from 1c0ca83 to a05d80c Compare December 8, 2022 18:25
@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

1 similar comment
@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

@dpgeorge
Copy link
Member

Thanks for this, I agree with the change. It's actually close to what I did in #6668, which adds support for async generators.

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Dec 13, 2022
@damz damz force-pushed the pr/uasyncio-generator branch from a05d80c to 74c5668 Compare December 13, 2022 16:22
@damz
Copy link
Contributor Author

damz commented Dec 13, 2022

@dpgeorge Thanks for the review. I updated the PR as requested.

@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

@damz damz force-pushed the pr/uasyncio-generator branch from 74c5668 to c8c8399 Compare December 13, 2022 16:35
@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

The compiler is not picky right now, but these are actually all syntax
errors:
- await is only valid in an async function
- async functions that use yield are actually async generators (a construct
  not supported by the compiler right now)
@dpgeorge dpgeorge force-pushed the pr/uasyncio-generator branch from c8c8399 to 0eba00a Compare December 14, 2022 02:30
@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

@dpgeorge dpgeorge merged commit 0eba00a into micropython:master Dec 14, 2022
@dpgeorge
Copy link
Member

Thanks for updating. Rebased and merged.

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Mar 31, 2025
Add guards to common_hal_pulseio_pulse(in|out)_deinit to prevent doub…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants