diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -2093,6 +2093,8 @@ Of course, parts are not generated if Vi or Ei is not present. */ +static PyObject * +dict_keys_inorder(PyObject *, int ); static int compiler_try_except(struct compiler *c, stmt_ty s) { @@ -2134,6 +2136,15 @@ } ADDOP(c, POP_TOP); if (handler->v.ExceptHandler.name) { + /* + printf("except name: %s\n", + PyUnicode_AsUTF8(handler->v.ExceptHandler.name)); + printf("locals: %s\n", PyObject_REPR(c->u->u_varnames)); + printf("locals2: %s\n", PyObject_REPR(dict_keys_inorder(c->u->u_varnames, 0))); + */ + if (PySequence_Contains(dict_keys_inorder(c->u->u_varnames, 0), + handler->v.ExceptHandler.name) == 1) + printf("SyntaxWarning!\n"); basicblock *cleanup_end, *cleanup_body; cleanup_end = compiler_new_block(c);