]> granicus.if.org Git - python/commitdiff
Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one...
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 7 Oct 2013 18:40:59 +0000 (20:40 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 7 Oct 2013 18:40:59 +0000 (20:40 +0200)
1  2 
Include/pyerrors.h
Misc/NEWS
Python/ceval.c

Simple merge
diff --cc Misc/NEWS
index 66c3c738f758e2f6dc8492fbe837022827587381,d7d5644a3f80ac38450e156cd67cdd356fd80193..f2d96953afccbd0a0c171ba1f3104ace341a9019
+++ b/Misc/NEWS
@@@ -10,83 -12,90 +10,86 @@@ Projected release date: 2013-10-2
  Core and Builtins
  -----------------
  
 -- Issue #19014: memoryview.cast() is now allowed on zero-length views.
 -
 -- Issue #19098: Prevent overflow in the compiler when the recursion limit is set
 -  absurdly high.
+ - Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at
+   least one place so as to avoid regressions.
 +- Issue #19087: Improve bytearray allocation in order to allow cheap popping
 +  of data at the front (slice deletion).
  
 -- Issue #18942: sys._debugmallocstats() output was damaged on Windows.
 +- Issue #19014: memoryview.cast() is now allowed on zero-length views.
  
 -- Issue #18667: Add missing "HAVE_FCHOWNAT" symbol to posix._have_functions.
 +- Issue #18690: memoryview is now automatically registered with
 +  collections.abc.Sequence
  
 -- Issue #18368: PyOS_StdioReadline() no longer leaks memory when realloc()
 -  fails.
 +- Issue #19078: memoryview now correctly supports the reversed builtin
 +  (Patch by Claudiu Popa)
  
 -- Issue #16741: Fix an error reporting in int().
 +Library
 +-------
  
 -- Issue #17899: Fix rare file descriptor leak in os.listdir().
 +- Issue #18716: Deprecate the formatter module.
  
 -- Issue #18552: Check return value of PyArena_AddPyObject() in
 -  obj2ast_object().
 +- Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
  
 -- Issue #18560: Fix potential NULL pointer dereference in sum().
 +- Issue #17839: base64.decodebytes and base64.encodebytes now accept any
 +  object that exports a 1 dimensional array of bytes (this means the same
 +  is now also true for base64_codec)
  
 -- Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
 -  prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
 +- Issue #19132: The pprint module now supports compact mode.
  
 -- Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all().
 +- Issue #19137: The pprint module now correctly formats instances of set and
 +  frozenset subclasses.
  
 -- Issue #17872: Fix a segfault in marshal.load() when input stream returns
 -  more bytes than requested.
 +- Issue #10042: functools.total_ordering now correctly handles
 +  NotImplemented being returned by the underlying comparison function (Patch
 +  by Katie Miller)
  
 -- Issue #18426: Fix NULL pointer dereference in C extension import when
 -  PyModule_GetDef() returns an error.
 +- Issue #19092: contextlib.ExitStack now correctly reraises exceptions
 +  from the __exit__ callbacks of inner context managers (Patch by Hrvoje
 +  Nikšić)
  
 -- Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the
 -  tstate is first removed from TLS and then deallocated.
 +- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
 +  when necessary.  Patch by Oscar Benjamin.
  
 -- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
 -  OverflowError when an argument of %c format is out of range.
 +- Issue #5845: In site.py, only load readline history from ~/.python_history
 +  if no history has been read already.  This avoids double writes to the
 +  history file at shutdown.
  
 -- Issue #18137: Detect integer overflow on precision in float.__format__()
 -  and complex.__format__().
 +- Properly initialize all fields of a SSL object after allocation.
  
 -- Issue #18183: Fix various unicode operations on strings with large unicode
 -  codepoints.
 +- Issue #19095: SSLSocket.getpeercert() now raises ValueError when the
 +  SSL handshake hasn't been done.
  
 -- Issue #18180: Fix ref leak in _PyImport_GetDynLoadWindows().
 +- Issue #4366: Fix building extensions on all platforms when --enable-shared
 +  is used.
  
 -- Issue #18038: SyntaxError raised during compilation sources with illegal
 -  encoding now always contains an encoding name.
 +Documentation
 +-------------
  
 -- Issue #17644: Fix a crash in str.format when curly braces are used in square
 -  brackets.
 +- Issue #18972: Modernize email examples and use the argparse module in them.
  
 -- Issue #17983: Raise a SyntaxError for a ``global __class__`` statement in a
 -  class body.
 +Build
 +-----
  
 -- Issue #17927: Frame objects kept arguments alive if they had been copied into
 -  a cell, even if the cell was cleared.
 +- Issue #19130: Correct PCbuild/readme.txt, Python 3.3 and 3.4 require VS 2010.
  
 -Library
 --------
  
 -- Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
 +What's New in Python 3.4.0 Alpha 3?
 +===================================
  
 -- Issue #19137: The pprint module now correctly formats instances of set and
 -  frozenset subclasses.
 +Release date: 2013-09-29
  
 -- Issue #19092: contextlib.ExitStack now correctly reraises exceptions
 -  from the __exit__ callbacks of inner context managers (Patch by Hrvoje
 -  Nikšić)
  
 -- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
 -  when necessary.  Patch by Oscar Benjamin.
 +Core and Builtins
 +-----------------
  
 -- Issue #18594: The fast path for collections.Counter() was never taken
 -  due to an over-restrictive type check.  And the fallback path did
 -  not implement the same algorithm as the pure python code.
 +- Issue #18818: The "encodingname" part of PYTHONIOENCODING is now optional.
  
 -- Properly initialize all fields of a SSL object after allocation.
 +- Issue #19098: Prevent overflow in the compiler when the recursion limit is set
 +  absurdly high.
  
 -- Issue #4366: Fix building extensions on all platforms when --enable-shared
 -  is used.
 +Library
 +-------
  
  - Issue #18950: Fix miscellaneous bugs in the sunau module.
    Au_read.readframes() now updates current file position and reads correct
diff --cc Python/ceval.c
index fcc1c24455f0a8302d8651c2fc89c73968adf6a7,faee5cd44d511358ea27e4e14f185b171de31926..dcfe8ec2aa3495fa38b76d5889bde97dce406227
@@@ -2092,79 -2029,64 +2092,79 @@@ PyEval_EvalFrameEx(PyFrameObject *f, in
                                  stack_pointer + totalargs)) {
                  stack_pointer += totalargs;
              } else {
 -                why = WHY_EXCEPTION;
 +                Py_DECREF(seq);
 +                goto error;
              }
 -            Py_DECREF(v);
 -            break;
 +            Py_DECREF(seq);
 +            DISPATCH();
          }
  
 -        TARGET(STORE_ATTR)
 -            w = GETITEM(names, oparg);
 -            v = TOP();
 -            u = SECOND();
 +        TARGET(STORE_ATTR) {
 +            PyObject *name = GETITEM(names, oparg);
 +            PyObject *owner = TOP();
 +            PyObject *v = SECOND();
 +            int err;
              STACKADJ(-2);
 -            err = PyObject_SetAttr(v, w, u); /* v.w = u */
 +            err = PyObject_SetAttr(owner, name, v);
              Py_DECREF(v);
 -            Py_DECREF(u);
 -            if (err == 0) DISPATCH();
 -            break;
 +            Py_DECREF(owner);
 +            if (err != 0)
 +                goto error;
 +            DISPATCH();
 +        }
  
 -        TARGET(DELETE_ATTR)
 -            w = GETITEM(names, oparg);
 -            v = POP();
 -            err = PyObject_SetAttr(v, w, (PyObject *)NULL);
 -                                            /* del v.w */
 -            Py_DECREF(v);
 -            break;
 +        TARGET(DELETE_ATTR) {
 +            PyObject *name = GETITEM(names, oparg);
 +            PyObject *owner = POP();
 +            int err;
 +            err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
 +            Py_DECREF(owner);
 +            if (err != 0)
 +                goto error;
 +            DISPATCH();
 +        }
  
 -        TARGET(STORE_GLOBAL)
 -            w = GETITEM(names, oparg);
 -            v = POP();
 -            err = PyDict_SetItem(f->f_globals, w, v);
 +        TARGET(STORE_GLOBAL) {
 +            PyObject *name = GETITEM(names, oparg);
 +            PyObject *v = POP();
 +            int err;
 +            err = PyDict_SetItem(f->f_globals, name, v);
              Py_DECREF(v);
 -            if (err == 0) DISPATCH();
 -            break;
 +            if (err != 0)
 +                goto error;
 +            DISPATCH();
 +        }
  
 -        TARGET(DELETE_GLOBAL)
 -            w = GETITEM(names, oparg);
 -            if ((err = PyDict_DelItem(f->f_globals, w)) != 0)
 +        TARGET(DELETE_GLOBAL) {
 +            PyObject *name = GETITEM(names, oparg);
 +            int err;
 +            err = PyDict_DelItem(f->f_globals, name);
 +            if (err != 0) {
                  format_exc_check_arg(
 -                    PyExc_NameError, GLOBAL_NAME_ERROR_MSG, w);
 -            break;
 +                    PyExc_NameError, NAME_ERROR_MSG, name);
 +                goto error;
 +            }
 +            DISPATCH();
 +        }
  
 -        TARGET(LOAD_NAME)
 -            w = GETITEM(names, oparg);
 -            if ((v = f->f_locals) == NULL) {
 +        TARGET(LOAD_NAME) {
 +            PyObject *name = GETITEM(names, oparg);
 +            PyObject *locals = f->f_locals;
 +            PyObject *v;
 +            if (locals == NULL) {
                  PyErr_Format(PyExc_SystemError,
 -                             "no locals when loading %R", w);
 -                why = WHY_EXCEPTION;
 -                break;
 +                             "no locals when loading %R", name);
 +                goto error;
              }
 -            if (PyDict_CheckExact(v)) {
 -                x = PyDict_GetItem(v, w);
 -                Py_XINCREF(x);
 +            if (PyDict_CheckExact(locals)) {
 +                v = PyDict_GetItem(locals, name);
 +                Py_XINCREF(v);
              }
              else {
 -                x = PyObject_GetItem(v, w);
 -                if (x == NULL && _PyErr_OCCURRED()) {
 -                    if (!PyErr_ExceptionMatches(
 -                                    PyExc_KeyError))
 -                        break;
 +                v = PyObject_GetItem(locals, name);
-                 if (v == NULL && PyErr_Occurred()) {
++                if (v == NULL && _PyErr_OCCURRED()) {
 +                    if (!PyErr_ExceptionMatches(PyExc_KeyError))
 +                        goto error;
                      PyErr_Clear();
                  }
              }
                      }
                  }
              }
 -            PUSH(x);
 +            PUSH(v);
              DISPATCH();
 +        }
  
 -        TARGET(LOAD_GLOBAL)
 -            w = GETITEM(names, oparg);
 +        TARGET(LOAD_GLOBAL) {
 +            PyObject *name = GETITEM(names, oparg);
 +            PyObject *v;
              if (PyDict_CheckExact(f->f_globals)
                  && PyDict_CheckExact(f->f_builtins)) {
 -                x = _PyDict_LoadGlobal((PyDictObject *)f->f_globals,
 +                v = _PyDict_LoadGlobal((PyDictObject *)f->f_globals,
                                         (PyDictObject *)f->f_builtins,
 -                                       w);
 -                if (x == NULL) {
 +                                       name);
 +                if (v == NULL) {
-                     if (!PyErr_Occurred())
+                     if (!_PyErr_OCCURRED())
                          format_exc_check_arg(PyExc_NameError,
 -                                             GLOBAL_NAME_ERROR_MSG, w);
 -                    break;
 +                                             NAME_ERROR_MSG, name);
 +                    goto error;
                  }
 -                Py_INCREF(x);
 +                Py_INCREF(v);
              }
              else {
                  /* Slow-path if globals or builtins is not a dict */