diff --git a/mypyc/lib-rt/exc_ops.c b/mypyc/lib-rt/exc_ops.c index 8c69664ae878..219914bf3470 100644 --- a/mypyc/lib-rt/exc_ops.c +++ b/mypyc/lib-rt/exc_ops.c @@ -243,7 +243,7 @@ void CPy_TypeErrorTraceback(const char *filename, const char *funcname, int line void CPy_AttributeError(const char *filename, const char *funcname, const char *classname, const char *attrname, int line, PyObject *globals) { char buf[500]; - snprintf(buf, sizeof(buf), "attribute '%.200s' of '%.200s' undefined", classname, attrname); + snprintf(buf, sizeof(buf), "attribute '%.200s' of '%.200s' undefined", attrname, classname); PyErr_SetString(PyExc_AttributeError, buf); CPy_AddTraceback(filename, funcname, line, globals); } diff --git a/mypyc/test-data/run-classes.test b/mypyc/test-data/run-classes.test index ea25e911ac37..0ed7b2c7fd2d 100644 --- a/mypyc/test-data/run-classes.test +++ b/mypyc/test-data/run-classes.test @@ -78,9 +78,9 @@ def test_delete() -> None: del c.x del c.y assert c.z == 3 - with assertRaises(AttributeError): + with assertRaises(AttributeError, "attribute 'x' of 'C' undefined"): c.x - with assertRaises(AttributeError): + with assertRaises(AttributeError, "attribute 'y' of 'C' undefined"): c.y def test_delete_any() -> None: