summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-30 06:15:31 (GMT)
committerGitHub <noreply@github.com>2017-03-30 06:15:31 (GMT)
commit762bf40438a572a398e500c74e38f9894ea20a45 (patch)
treee3cec204dd4f633631650bf10222344a2c605929 /Tools
parentea720fe7e99d68924deab38de955fe97f87e2b29 (diff)
downloadcpython-762bf40438a572a398e500c74e38f9894ea20a45.zip
cpython-762bf40438a572a398e500c74e38f9894ea20a45.tar.gz
cpython-762bf40438a572a398e500c74e38f9894ea20a45.tar.bz2
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
if pass `accept={int, NoneType}`.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 53108b1..1d570f1 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -2650,12 +2650,20 @@ class unsigned_long_long_converter(CConverter):
if not bitwise:
fail("Unsigned long long must be bitwise (for now).")
+
class Py_ssize_t_converter(CConverter):
type = 'Py_ssize_t'
- default_type = int
- format_unit = 'n'
c_ignored_default = "0"
+ def converter_init(self, *, accept={int}):
+ if accept == {int}:
+ self.format_unit = 'n'
+ self.default_type = int
+ elif accept == {int, NoneType}:
+ self.converter = '_Py_convert_optional_to_ssize_t'
+ else:
+ fail("Py_ssize_t_converter: illegal 'accept' argument " + repr(accept))
+
class slice_index_converter(CConverter):
type = 'Py_ssize_t'