Skip to content

Commit f66b992

Browse files
[3.12] gh-106368: Add test for Argument Clinic misbehaving custom converter_init() (GH-107496) (#107499)
(cherry picked from commit 2c5d206) Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 9f58d9e commit f66b992

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Lib/test/test_clinic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,26 @@ def test_unknown_destination_command(self):
314314
msg = "unknown destination command 'nosuchcommand'"
315315
self.assertIn(msg, out)
316316

317+
def test_no_access_to_members_in_converter_init(self):
318+
out = self.expect_failure("""
319+
/*[python input]
320+
class Custom_converter(CConverter):
321+
converter = "some_c_function"
322+
def converter_init(self):
323+
self.function.noaccess
324+
[python start generated code]*/
325+
/*[clinic input]
326+
module test
327+
test.fn
328+
a: Custom
329+
[clinic start generated code]*/
330+
""")
331+
msg = (
332+
"Stepped on a land mine, trying to access attribute 'noaccess':\n"
333+
"Don't access members of self.function inside converter_init!"
334+
)
335+
self.assertIn(msg, out)
336+
317337

318338
class ClinicGroupPermuterTest(TestCase):
319339
def _test(self, l, m, r, output):

0 commit comments

Comments
 (0)