Merged
Conversation
I actually wanted to implement this but it turns out that Python 3.14 does this automatically for us (this doesn't "just work" in Python 3.13). Since we're using the release candidate for the not-yet-released 3.14, that's fine. I however decided to add a guard/check so nobody tries to run our WASM payload with an older version (or a too-new one).
Collaborator
Author
|
Here's why this works now: Python 3.14.0rc2 (tags/v3.14.0rc2-dirty:31967d8, Aug 14 2025, 12:19:47) [Clang 18.1.2-wasi-sdk (https://github.com/llvm/llvm-project 26a1d6601d727a96f43 on wasi
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: No module named 'termios'
>>> import typing
>>> import types
>>> x = typing.Optional[int]
>>> type(x)
<class 'typing.Union'>
>>> x.__args__
(<class 'int'>, <class 'NoneType'>)
>>>
>>> y = int | None
>>> type(y)
<class 'typing.Union'>
>>> y.__args__
(<class 'int'>, <class 'NoneType'>)but this didn't used to work in older versions of Python: Python 3.13.7 (main, Aug 15 2025, 12:34:02) [GCC 15.2.1 20250813] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> import types
>>> x = typing.Optional[int]
>>> type(x)
<class 'typing._UnionGenericAlias'>
>>> x.__args__
(<class 'int'>, <class 'NoneType'>)
>>>
>>> y = int | None
>>> type(y)
<class 'types.UnionType'>
>>> y.__args__
(<class 'int'>, <class 'NoneType'>)so |
jdockerty
approved these changes
Sep 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I actually wanted to implement this but it turns out that Python 3.14 does this automatically for us (this doesn't "just work" in Python 3.13). Since we're using the release candidate for the not-yet-released 3.14, that's fine. I however decided to add a guard/check so nobody tries to run our WASM payload with an older version (or a too-new one).