[issue28933] AC: Accept None as a Py_ssize_t default value
Julien Palard
report at bugs.python.org
Sun Dec 11 00:24:04 EST 2016
Julien Palard added the comment:
> You propose an automatic conversion of "None" into "-1"? That's awful. Please don't commit that patch to CPython.
Not really, I propose a way to do it with AC when needed. And the AC semantics introduced are not "Automatic conversion of None into -1" but "automatic "don't touch the C default" when the python default is given", so it's reusable for other values:
something: Py_ssize_t(c_default="-1") = None
something: Py_ssize_t(c_default="0") = None
something: Py_ssize_t(c_default="42") = None
…
And this semantic can be extended to other types too if needed:
something: a_type(c_default="a_c_side_default_value") = None
To get "a_c_side_default_value" when None is given.
I however did not introduced a way to keep the C default value by using something else than None in the Python side:
- I'm not sure this is usefull to allow it but it can still be implemented if needed
- Limiting to None permits to keep a type check so ``something: Py_ssize_t(c_default="-1") = "bar"`` will still fail at clinic.py runtime.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28933>
_______________________________________
More information about the Python-bugs-list
mailing list