Skip to content

Commit 2c5d206

Browse files
gh-106368: Add test for Argument Clinic misbehaving custom converter_init() (#107496)
1 parent a1c737b commit 2c5d206

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
@@ -318,6 +318,26 @@ def test_unknown_destination_command(self):
318318
msg = "unknown destination command 'nosuchcommand'"
319319
self.assertIn(msg, out)
320320

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

322342
class ClinicGroupPermuterTest(TestCase):
323343
def _test(self, l, m, r, output):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy