Skip to content

Commit 3cb999d

Browse files
committed
Test undecodable name
1 parent 7cc691d commit 3cb999d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/test/test_capi/test_object.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ class Obj:
266266
self.assertIsNone(cm.exception.__cause__)
267267
self.assertHasAttr(obj, 'attr')
268268

269+
with self.assertRaises(SystemError) as cm:
270+
# undecodable name
271+
_testcapi.object_setattrstring_null_exc(obj, b'\xff', exc)
272+
self.assertIs(cm.exception.__context__, exc)
273+
self.assertIsNone(cm.exception.__cause__)
274+
self.assertHasAttr(obj, 'attr')
275+
269276

270277
if __name__ == "__main__":
271278
unittest.main()

Modules/_testcapi/abstract.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ object_setattrstring_null_exc(PyObject *self, PyObject *args)
200200
{
201201
PyObject *obj, *exc;
202202
const char *name;
203-
if (!PyArg_ParseTuple(args, "OsO", &obj, &name, &exc)) {
203+
Py_ssize_t size;
204+
if (!PyArg_ParseTuple(args, "Oz#O", &obj, &name, &size, &exc)) {
204205
return NULL;
205206
}
206207

0 commit comments

Comments
 (0)