bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)

if pass `accept={int, NoneType}`.
This commit is contained in:
Serhiy Storchaka 2017-03-30 09:15:31 +03:00 committed by GitHub
parent ea720fe7e9
commit 762bf40438
20 changed files with 98 additions and 200 deletions

View file

@ -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'