diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-07-26 10:22:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-26 10:22:16 (GMT) |
commit | 7cb7bcff20a386bba59cbc51e2419542de358bd2 (patch) | |
tree | f5d46faf7a7ddd3b427de7de8a74a1fb37fe2993 /Tools | |
parent | 323748ad7446c76972c80dbbf510534dc5c22ae8 (diff) | |
download | cpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.zip cpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.tar.gz cpython-7cb7bcff20a386bba59cbc51e2419542de358bd2.tar.bz2 |
bpo-20260: Implement non-bitwise unsigned int converters for Argument Clinic. (GH-8434)
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/clinic/clinic.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index e7c7eb4..653afbe 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -2603,12 +2603,13 @@ class short_converter(CConverter): class unsigned_short_converter(CConverter): type = 'unsigned short' default_type = int - format_unit = 'H' c_ignored_default = "0" def converter_init(self, *, bitwise=False): - if not bitwise: - fail("Unsigned shorts must be bitwise (for now).") + if bitwise: + self.format_unit = 'H' + else: + self.converter = '_PyLong_UnsignedShort_Converter' @add_legacy_c_converter('C', accept={str}) class int_converter(CConverter): @@ -2628,12 +2629,13 @@ class int_converter(CConverter): class unsigned_int_converter(CConverter): type = 'unsigned int' default_type = int - format_unit = 'I' c_ignored_default = "0" def converter_init(self, *, bitwise=False): - if not bitwise: - fail("Unsigned ints must be bitwise (for now).") + if bitwise: + self.format_unit = 'I' + else: + self.converter = '_PyLong_UnsignedInt_Converter' class long_converter(CConverter): type = 'long' @@ -2644,12 +2646,13 @@ class long_converter(CConverter): class unsigned_long_converter(CConverter): type = 'unsigned long' default_type = int - format_unit = 'k' c_ignored_default = "0" def converter_init(self, *, bitwise=False): - if not bitwise: - fail("Unsigned longs must be bitwise (for now).") + if bitwise: + self.format_unit = 'k' + else: + self.converter = '_PyLong_UnsignedLong_Converter' class long_long_converter(CConverter): type = 'long long' @@ -2660,13 +2663,13 @@ class long_long_converter(CConverter): class unsigned_long_long_converter(CConverter): type = 'unsigned long long' default_type = int - format_unit = 'K' c_ignored_default = "0" def converter_init(self, *, bitwise=False): - if not bitwise: - fail("Unsigned long long must be bitwise (for now).") - + if bitwise: + self.format_unit = 'K' + else: + self.converter = '_PyLong_UnsignedLongLong_Converter' class Py_ssize_t_converter(CConverter): type = 'Py_ssize_t' @@ -2693,6 +2696,11 @@ class slice_index_converter(CConverter): else: fail("slice_index_converter: illegal 'accept' argument " + repr(accept)) +class size_t_converter(CConverter): + type = 'size_t' + converter = '_PyLong_Size_t_Converter' + c_ignored_default = "0" + class float_converter(CConverter): type = 'float' |