]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104683: Argument clinic: pass `clinic` as a parameter where possible (#107435)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Sat, 29 Jul 2023 18:47:42 +0000 (19:47 +0100)
committerGitHub <noreply@github.com>
Sat, 29 Jul 2023 18:47:42 +0000 (19:47 +0100)
Tools/clinic/clinic.py

index 3c16dc389e3ebc7b19de60117cf2415e8644a6da..defe703b825b1671a60ede3d8a2249ead21b6dfb 100755 (executable)
@@ -805,7 +805,8 @@ class CLanguage(Language):
 
     def output_templates(
             self,
-            f: Function
+            f: Function,
+            clinic: Clinic
     ) -> dict[str, str]:
         parameters = list(f.parameters.values())
         assert parameters
@@ -1324,7 +1325,6 @@ class CLanguage(Language):
             cpp_if = "#if " + conditional
             cpp_endif = "#endif /* " + conditional + " */"
 
-            assert clinic is not None
             if methoddef_define and f.full_name not in clinic.ifndef_symbols:
                 clinic.ifndef_symbols.add(f.full_name)
                 methoddef_ifndef = normalize_snippet("""
@@ -1490,7 +1490,7 @@ class CLanguage(Language):
         parameters = f.render_parameters
         converters = [p.converter for p in parameters]
 
-        templates = self.output_templates(f)
+        templates = self.output_templates(f, clinic)
 
         f_self = parameters[0]
         selfless = parameters[1:]
@@ -4613,7 +4613,7 @@ class DSLParser:
         self.next(self.state_terminal)
         self.state(None)
 
-        block.output.extend(self.clinic.language.render(clinic, block.signatures))
+        block.output.extend(self.clinic.language.render(self.clinic, block.signatures))
 
         if self.preserve_output:
             if block.output: