Skip to content

Commit b1548b6

Browse files
Update exc_ops.c
1 parent 64ca907 commit b1548b6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mypyc/lib-rt/exc_ops.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,11 @@ void CPy_AttributeError(const char *filename, const char *funcname, const char *
256256
snprintf(buf, sizeof(buf), "attribute '%.200s' of '%.200s' undefined", attrname, classname);
257257
PyErr_SetString(PyExc_AttributeError, buf);
258258
CPy_AddTraceback(filename, funcname, line, globals);
259+
260+
void CPy_UnboundLocalError(const char *filename, const char *funcname, const char *attrname,
261+
int line, PyObject *globals) {
262+
char buf[500];
263+
snprintf(buf, sizeof(buf), "local variable '%.200s' referenced before assignment", attrname);
264+
PyErr_SetString(PyExc_UnboundLocalError, buf);
265+
CPy_AddTraceback(filename, funcname, line, globals);
259266
}

0 commit comments

Comments
 (0)