diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index 84ceafabd68..ef56b889f5a 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -272,19 +272,8 @@ def f(): inner() y = 1 - try: - errorInOuter() - except UnboundLocalError: - pass - else: - self.fail() - - try: - errorInInner() - except NameError: - pass - else: - self.fail() + self.assertRaises(UnboundLocalError, errorInOuter) + self.assertRaises(NameError, errorInInner) # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation exec(""" diff --git a/Python/peephole.c b/Python/peephole.c index 23735b0a31a..91630912725 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -330,7 +330,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Bail out if an exception is set */ if (PyErr_Occurred()) - goto exitUnchanged; + goto exitError; /* Bypass optimization when the lineno table is too complex */ assert(PyBytes_Check(lineno_obj)); @@ -348,7 +348,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Make a modifiable copy of the code string */ codestr = (unsigned char *)PyMem_Malloc(codelen); if (codestr == NULL) - goto exitUnchanged; + goto exitError; codestr = (unsigned char *)memcpy(codestr, PyBytes_AS_STRING(code), codelen); @@ -363,11 +363,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Mapping to new jump targets after NOPs are removed */ addrmap = (int *)PyMem_Malloc(codelen * sizeof(int)); if (addrmap == NULL) - goto exitUnchanged; + goto exitError; blocks = markblocks(codestr, codelen); if (blocks == NULL) - goto exitUnchanged; + goto exitError; assert(PyList_Check(consts)); for (i=0 ; i