Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c5d206

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

File tree

Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed

‎Lib/test/test_clinic.py

Copy file name to clipboardExpand all lines: Lib/test/test_clinic.py
+20Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.