mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
if pass `accept={int, NoneType}`.
This commit is contained in:
parent
ea720fe7e9
commit
762bf40438
20 changed files with 98 additions and 200 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue