| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent efe7256 commit ebe95fd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,20 +27,20 @@ class Py_complex_protected_return_converter(CReturnConverter): | |||
| 27 | 27 | self.declare(data) | |
| 28 | 28 | data.return_conversion.append(""" | |
| 29 | 29 | PyFPE_END_PROTECT(_return_value); | |
| 30 | - if (errno == EDOM) {{ | ||
| 30 | + if (errno == EDOM) { | ||
| 31 | 31 | PyErr_SetString(PyExc_ValueError, "math domain error"); | |
| 32 | 32 | goto exit; | |
| 33 | - }} | ||
| 34 | - else if (errno == ERANGE) {{ | ||
| 33 | + } | ||
| 34 | + else if (errno == ERANGE) { | ||
| 35 | 35 | PyErr_SetString(PyExc_OverflowError, "math range error"); | |
| 36 | 36 | goto exit; | |
| 37 | - }} | ||
| 38 | - else {{ | ||
| 37 | + } | ||
| 38 | + else { | ||
| 39 | 39 | return_value = PyComplex_FromCComplex(_return_value); | |
| 40 | - }} | ||
| 40 | + } | ||
| 41 | 41 | """.strip()) | |
| 42 | 42 | [python start generated code]*/ | |
| 43 | - /*[python end generated code: output=da39a3ee5e6b4b0d input=231019039a6fbb9a]*/ | ||
| 43 | + /*[python end generated code: output=da39a3ee5e6b4b0d input=345daa075b1028e7]*/ | ||
| 44 | 44 | ||
| 45 | 45 | #if (FLT_RADIX != 2 && FLT_RADIX != 16) | |
| 46 | 46 | #error "Modules/cmathmodule.c expects FLT_RADIX to be 2 or 16" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,6 +176,13 @@ def rstrip_lines(s): | |||
| 176 | 176 | text.pop() | |
| 177 | 177 | return output() | |
| 178 | 178 | ||
| 179 | + def format_escape(s): | ||
| 180 | + # double up curly-braces, this string will be used | ||
| 181 | + # as part of a format_map() template later | ||
| 182 | + s = s.replace('{', '{{') | ||
| 183 | + s = s.replace('}', '}}') | ||
| 184 | + return s | ||
| 185 | + | ||
| 179 | 186 | def linear_format(s, **kwargs): | |
| 180 | 187 | """ | |
| 181 | 188 | Perform str.format-like substitution, except: | |
@@ -996,7 +1003,7 @@ def render_option_group_parsing(self, f, template_dict): | |||
| 996 | 1003 | count_min = sys.maxsize | |
| 997 | 1004 | count_max = -1 | |
| 998 | 1005 | ||
| 999 | - add("switch (PyTuple_GET_SIZE(args)) {{\n") | ||
| 1006 | + add("switch (PyTuple_GET_SIZE(args)) {\n") | ||
| 1000 | 1007 | for subset in permute_optional_groups(left, required, right): | |
| 1001 | 1008 | count = len(subset) | |
| 1002 | 1009 | count_min = min(count_min, count) | |
@@ -1012,7 +1019,6 @@ def render_option_group_parsing(self, f, template_dict): | |||
| 1012 | 1019 | d = {} | |
| 1013 | 1020 | d['count'] = count | |
| 1014 | 1021 | d['name'] = f.name | |
| 1015 | - d['groups'] = sorted(group_ids) | ||
| 1016 | 1022 | d['format_units'] = "".join(p.converter.format_unit for p in subset) | |
| 1017 | 1023 | ||
| 1018 | 1024 | parse_arguments = [] | |
@@ -1039,8 +1045,8 @@ def render_option_group_parsing(self, f, template_dict): | |||
| 1039 | 1045 | s = ' PyErr_SetString(PyExc_TypeError, "{} requires {} to {} arguments");\n' | |
| 1040 | 1046 | add(s.format(f.full_name, count_min, count_max)) | |
| 1041 | 1047 | add(' goto exit;\n') | |
| 1042 | - add("}}") | ||
| 1043 | - template_dict['option_group_parsing'] = output() | ||
| 1048 | + add("}") | ||
| 1049 | + template_dict['option_group_parsing'] = format_escape(output()) | ||
| 1044 | 1050 | ||
| 1045 | 1051 | def render_function(self, clinic, f): | |
| 1046 | 1052 | if not f: | |
@@ -1135,16 +1141,16 @@ def render_function(self, clinic, f): | |||
| 1135 | 1141 | f.return_converter.render(f, data) | |
| 1136 | 1142 | template_dict['impl_return_type'] = f.return_converter.type | |
| 1137 | 1143 | ||
| 1138 | - template_dict['declarations'] = "\n".join(data.declarations) | ||
| 1144 | + template_dict['declarations'] = format_escape("\n".join(data.declarations)) | ||
| 1139 | 1145 | template_dict['initializers'] = "\n\n".join(data.initializers) | |
| 1140 | 1146 | template_dict['modifications'] = '\n\n'.join(data.modifications) | |
| 1141 | 1147 | template_dict['keywords'] = '"' + '", "'.join(data.keywords) + '"' | |
| 1142 | 1148 | template_dict['format_units'] = ''.join(data.format_units) | |
| 1143 | 1149 | template_dict['parse_arguments'] = ', '.join(data.parse_arguments) | |
| 1144 | 1150 | template_dict['impl_parameters'] = ", ".join(data.impl_parameters) | |
| 1145 | 1151 | template_dict['impl_arguments'] = ", ".join(data.impl_arguments) | |
| 1146 | - template_dict['return_conversion'] = "".join(data.return_conversion).rstrip() | ||
| 1147 | - template_dict['cleanup'] = "".join(data.cleanup) | ||
| 1152 | + template_dict['return_conversion'] = format_escape("".join(data.return_conversion).rstrip()) | ||
| 1153 | + template_dict['cleanup'] = format_escape("".join(data.cleanup)) | ||
| 1148 | 1154 | template_dict['return_value'] = data.return_value | |
| 1149 | 1155 | ||
| 1150 | 1156 | # used by unpack tuple code generator | |
@@ -2439,12 +2445,7 @@ def declaration(self): | |||
| 2439 | 2445 | declaration.append('\nPy_ssize_clean_t ') | |
| 2440 | 2446 | declaration.append(self.length_name()) | |
| 2441 | 2447 | declaration.append(';') | |
| 2442 | - s = "".join(declaration) | ||
| 2443 | - # double up curly-braces, this string will be used | ||
| 2444 | - # as part of a format_map() template later | ||
| 2445 | - s = s.replace("{", "{{") | ||
| 2446 | - s = s.replace("}", "}}") | ||
| 2447 | - return s | ||
| 2448 | + return "".join(declaration) | ||
| 2448 | 2449 | ||
| 2449 | 2450 | def initialize(self): | |
| 2450 | 2451 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments