Skip to content

Commit

Permalink
[3.11] gh-106368: Add test for Argument Clinic misbehaving custom con…
Browse files Browse the repository at this point in the history
…verter_init() (GH-107496) (#107500)

(cherry picked from commit 2c5d206)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
  • Loading branch information
miss-islington and erlend-aasland committed Jul 31, 2023
1 parent 3abcdc7 commit 81d0c7c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,26 @@ def test_unknown_destination_command(self):
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):
Expand Down

0 comments on commit 81d0c7c

Please sign in to comment.