diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-06 18:34:00 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-06 18:34:00 (GMT) |
commit | 3f144c2ad76ed16bd2c40fd3c624fb6009ee8aa2 (patch) | |
tree | 1ab68c6b32ddcde6119e6df2e1670d2a3d7723f4 /Tools/clinic | |
parent | b7f5dcadf2a929a92cfd5d0386426bc143cb01b4 (diff) | |
download | cpython-3f144c2ad76ed16bd2c40fd3c624fb6009ee8aa2.zip cpython-3f144c2ad76ed16bd2c40fd3c624fb6009ee8aa2.tar.gz cpython-3f144c2ad76ed16bd2c40fd3c624fb6009ee8aa2.tar.bz2 |
Issue #20142: Py_buffer variables generated by Argument Clinic are now
initialized with a default value.
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-x | Tools/clinic/clinic.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 44456a7..023a034 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -1488,7 +1488,12 @@ class CConverter(metaclass=CConverterAutoRegister): declaration.append('\nPy_ssize_clean_t ') declaration.append(self.length_name()) declaration.append(';') - return "".join(declaration) + s = "".join(declaration) + # double up curly-braces, this string will be used + # as part of a format_map() template later + s = s.replace("{", "{{") + s = s.replace("}", "}}") + return s def initialize(self): """ @@ -1742,6 +1747,9 @@ class Py_buffer_converter(CConverter): c_ignored_default = "{NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL}" def converter_init(self, *, types='bytes bytearray buffer', nullable=False): + if self.default != unspecified: + fail("There is no legal default value for Py_buffer ") + self.c_default = self.c_ignored_default types = set(types.strip().split()) bytes_type = set(('bytes',)) bytearray_type = set(('bytearray',)) |