From b922ce98afff5b0db93e58156c67a8fd57daeba7 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 11 Aug 2022 13:13:52 +0100 Subject: [PATCH] [mypyc] Fix AttributeError message Previously this would be `attribute 'ClsName' of 'attr_name' undefined`. Now it's `attribute 'attr_name' of 'ClsName' undefined`. --- mypyc/lib-rt/exc_ops.c | 2 +- mypyc/test-data/run-classes.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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: