From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:32:18 +0000 (-0700) Subject: [3.11] gh-106368: Add test for Argument Clinic misbehaving custom converter_init... X-Git-Tag: v3.11.5~105 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81d0c7ca5aa6b2f86eb9ae5b66946c54dd483548;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-106368: Add test for Argument Clinic misbehaving custom converter_init() (GH-107496) (#107500) (cherry picked from commit 2c5d206b33e4cdcafaaaf1eeaa189c10de332dc5) Co-authored-by: Erlend E. Aasland --- diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py index 1c01fb0ed368..bc0eee1552e4 100644 --- a/Lib/test/test_clinic.py +++ b/Lib/test/test_clinic.py @@ -314,6 +314,26 @@ class ClinicWholeFileTest(_ParserBase): msg = "unknown destination command 'nosuchcommand'" self.assertIn(msg, out) + def test_no_access_to_members_in_converter_init(self): + out = self.expect_failure(""" + /*[python input] + class Custom_converter(CConverter): + converter = "some_c_function" + def converter_init(self): + self.function.noaccess + [python start generated code]*/ + /*[clinic input] + module test + test.fn + a: Custom + [clinic start generated code]*/ + """) + msg = ( + "Stepped on a land mine, trying to access attribute 'noaccess':\n" + "Don't access members of self.function inside converter_init!" + ) + self.assertIn(msg, out) + class ClinicGroupPermuterTest(TestCase): def _test(self, l, m, r, output):