Skip to content

Commit 9242046

Browse files
authored
[mypyc] Fix AttributeError message (#13382)
Previously this would be `attribute 'ClsName' of 'attr_name' undefined`. Now it's `attribute 'attr_name' of 'ClsName' undefined`.
1 parent cba07d7 commit 9242046

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mypyc/lib-rt/exc_ops.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void CPy_TypeErrorTraceback(const char *filename, const char *funcname, int line
243243
void CPy_AttributeError(const char *filename, const char *funcname, const char *classname,
244244
const char *attrname, int line, PyObject *globals) {
245245
char buf[500];
246-
snprintf(buf, sizeof(buf), "attribute '%.200s' of '%.200s' undefined", classname, attrname);
246+
snprintf(buf, sizeof(buf), "attribute '%.200s' of '%.200s' undefined", attrname, classname);
247247
PyErr_SetString(PyExc_AttributeError, buf);
248248
CPy_AddTraceback(filename, funcname, line, globals);
249249
}

mypyc/test-data/run-classes.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def test_delete() -> None:
7878
del c.x
7979
del c.y
8080
assert c.z == 3
81-
with assertRaises(AttributeError):
81+
with assertRaises(AttributeError, "attribute 'x' of 'C' undefined"):
8282
c.x
83-
with assertRaises(AttributeError):
83+
with assertRaises(AttributeError, "attribute 'y' of 'C' undefined"):
8484
c.y
8585

8686
def test_delete_any() -> None:

0 commit comments

Comments
 (0)