[3.14] gh-135855: Raise TypeError When Passing Non-dict Object to _interpreters.set___main___attrs (gh-135900)

(cherry picked from commit 4e6f0d116, AKA gh-135856)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-06-24 21:19:31 +02:00 committed by GitHub
parent fa74331a4c
commit 090a42b5eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 12 deletions

View file

@ -485,6 +485,21 @@ def test_signatures(self):
msg = r'_interpreters.run_func\(\) argument 3 must be dict, not int'
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=1)
# See https://github.com/python/cpython/issues/135855
msg = r'_interpreters.set___main___attrs\(\) argument 2 must be dict, not int'
with self.assertRaisesRegex(TypeError, msg):
_interpreters.set___main___attrs(self.id, 1)
def test_invalid_shared_none(self):
msg = r'must be dict, not None'
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', shared=None)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_string(self.id, 'a', shared=None)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=None)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.set___main___attrs(self.id, None)
def test_invalid_shared_encoding(self):
# See https://github.com/python/cpython/issues/127196