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
[BUG] not None
semantics is not supported in Pure Python mode for memory views
#5612
Comments
The difficulty is backwards compatibility (i.e. Cython 3 was probably the time to make this change is we wanted to). I think we'd probably have to introduce a We should definitely make sure Much as it'd be nice to make it consistent. |
As much as I'd dislike making incompatible changes at this point, we could still admit a mistake and change it right in 3.0.1, so that users can depend on that onwards. Pure Python mode hasn't been used much in the past, so we're mostly talking about newly written, still maintained code here that doesn't need to work in Cython 0.29.x.
Also, this is the behaviour that most users would expect or at least want, so it's not like we're really talking something away.
I'd certainly prefer using the standard Optional[] mechanism over anything special that we could come up with ourselves. Special cases aren't special enough to break the rules. This one really doesn't feel like it should be special.
|
OK I have created PoC PR fixing this issue. Not tested yet. I will wait for final decision whether we will go with it to 3.0.1 (as @scoder suggested) or not. |
On a loosely related note, should we allow Or do you think that we should limit the applicable range of |
I don't have strong opinion about this. But I would rather do it later not in this PR or 3.0.1 release (to keep it light). This change is not breaking anything so can be added anytime. |
Describe the bug
Pure python mode does not support
not None
when used with memory views. See examples below.Code to reproduce the behaviour:
Expected behaviour
TypeError
is raised in the same way as it is raised in cython version:Also
typing.Optional[]
of memoryview succeeds without error.OS
any
Python version
3.9
Cython version
master
Additional context
Similar semantics is already present in Extension types: https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#extension-types-and-none
The text was updated successfully, but these errors were encountered: