Skip to content

Commit

Permalink
[mypyc] Fix AttributeError message (#13382)
Browse files Browse the repository at this point in the history
Previously this would be `attribute 'ClsName' of 'attr_name' undefined`.
Now it's `attribute 'attr_name' of 'ClsName' undefined`.
  • Loading branch information
JukkaL authored Aug 11, 2022
1 parent cba07d7 commit 9242046
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mypyc/lib-rt/exc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions mypyc/test-data/run-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9242046

Please sign in to comment.