Commit Graph

686 Commits

Author SHA1 Message Date
Victor Stinner 13a1c6022b Merge 3.4 (generator) 2015-01-31 11:08:40 +01:00
Victor Stinner 26f7b8acdc Issue #23353: Fix the exception handling of generators in PyEval_EvalFrameEx().
At entry, save or swap the exception state even if PyEval_EvalFrameEx() is
called with throwflag=0. At exit, the exception state is now always restored or
swapped, not only if why is WHY_YIELD or WHY_RETURN. Patch co-written with
Antoine Pitrou.
2015-01-31 10:29:47 +01:00
Victor Stinner 0b881dd50f Issue #18028: Fix aliasing issue in READ_TIMESTAMP() of ceval.c on x86_64,
when Python is configure with --with-tsc. Patch written by Christian Heimes.
2014-12-12 13:17:41 +01:00
Victor Stinner 60b33cc6a5 Merge 3.4 (ceval.c) 2014-12-12 13:19:48 +01:00
Antoine Pitrou 0373a106a1 Issue #17636: Circular imports involving relative imports are now supported. 2014-10-13 20:19:45 +02:00
Benjamin Peterson e6bfdb9ca5 merge 3.4 2014-06-16 23:07:15 -07:00
Benjamin Peterson 17548dda51 check if the thread is finalizing after retaking the GIL 2014-06-16 22:59:07 -07:00
Victor Stinner 40ee30181f Issue #21205: Add a new ``__qualname__`` attribute to generator, the qualified
name, and use it in the representation of a generator (``repr(gen)``). The
default name of the generator (``__name__`` attribute) is now get from the
function instead of the code. Use ``gen.gi_code.co_name`` to get the name of
the code.
2014-06-16 15:59:28 +02:00
Benjamin Peterson a548a30fed merge 3.4 (#21209) 2014-04-13 23:52:43 -04:00
Benjamin Peterson f6e50b4a81 fix sending tuples to custom generator objects with yield from (closes #21209)
Debugged by Victor.
2014-04-13 23:52:01 -04:00
Benjamin Peterson d51374ed78 PEP 465: a dedicated infix operator for matrix multiplication (closes #21176) 2014-04-09 23:55:56 -04:00
Serhiy Storchaka dfe98a102e Issue #20437: Fixed 22 potential bugs when deleting objects references. 2014-02-09 13:46:20 +02:00
Serhiy Storchaka 505ff755d7 Issue #20437: Fixed 21 potential bugs when deleting objects references. 2014-02-09 13:33:53 +02:00
Victor Stinner fdeb6ec45a Issue #14432: Remove the thread state field from the frame structure. Fix a
crash when a generator is created in a C thread that is destroyed while the
generator is still used. The issue was that a generator contains a frame, and
the frame kept a reference to the Python state of the destroyed C thread. The
crash occurs when a trace function is setup.
2013-12-13 02:01:38 +01:00
Antoine Pitrou 8933521b3d Fix refleak introduced by 4f730c045f5f (issue #18408) and unveiled by 95eea8624d05 (issue #16596). 2013-11-23 14:05:23 +01:00
Guido van Rossum 8820c239f7 Better behavior when stepping over yield[from]. Fixes issue 16596. By Xavier de Gaye. 2013-11-21 11:30:06 -08:00
Victor Stinner cab75e3e1e Issue #19512: PRINT_EXPR bytecode now uses an identifier to get sys.displayhook
to only create the "displayhook" string once
2013-11-06 22:38:37 +01:00
Benjamin Peterson 96c03df771 merge 3.3 2013-10-29 22:25:55 -04:00
Benjamin Peterson 8f169489c4 update comment 2013-10-29 22:25:06 -04:00
Victor Stinner 41bb43a71e Issue #18408: Add a new PyFrame_FastToLocalsWithError() function to handle
exceptions when merging fast locals into f_locals of a frame.
PyEval_GetLocals() now raises an exception and return NULL on failure.
2013-10-29 01:19:37 +01:00
Victor Stinner 8d19767403 Close #19199: Remove ``PyThreadState.tick_counter`` field 2013-10-09 14:53:01 +02:00
Antoine Pitrou 1cfa0ba883 Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions. 2013-10-07 20:40:59 +02:00
Antoine Pitrou 59c900d3bf Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions. 2013-10-07 20:38:51 +02:00
Antoine Pitrou 9ed5f27266 Issue #18722: Remove uses of the "register" keyword in C code. 2013-08-13 20:18:52 +02:00
Antoine Pitrou 58720d6145 Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles. 2013-08-05 23:26:40 +02:00
Christian Heimes 895bdfb16e Add missing check of PyDict_SetItem()'s return value in PyEval_EvalCodeEx()
CID 486647
2013-07-20 14:48:21 +02:00
Christian Heimes 0bd447f847 Add missing check of PyDict_SetItem()'s return value in PyEval_EvalCodeEx()
CID 486647
2013-07-20 14:48:10 +02:00
Victor Stinner ace47d7efd Issue #18408: PyEval_EvalFrameEx() and PyEval_CallObjectWithKeywords() now fail
with an assertion error if they are called with an exception set
(PyErr_Occurred()).

If these functions are called with an exception set, the exception may be
cleared and so the caller looses its exception.

Add also assertions to PyEval_CallObjectWithKeywords() and call_function() to
check if the function succeed with no exception set, or the function failed
with an exception set.
2013-07-18 01:41:08 +02:00
Victor Stinner f243ee4055 Issue #18408: add more assertions on PyErr_Occurred() in ceval.c to detect bugs
earlier
2013-07-16 01:02:12 +02:00
Victor Stinner 7eab0d000c Issue #18408: Fix PyEval_EvalFrameEx() for MemoryError
Don't pass a NULL traceback to PyException_SetTraceback(): pass Py_None.
Passing NULL would raise a new exception.
2013-07-15 21:16:27 +02:00
Brett Cannon a79e4fb38d Issue #18342: Use the repr of a module name for ``from ... import
...`` when an ImportError occurs.

Other cases had already been switched over to using the repr.

Thanks to Tomasz Maćkowiak for the patch.
2013-07-12 11:22:26 -04:00
Victor Stinner 365b693adc Issue #18408: ceval.c: in debug mode, convert the PyErr_Occurred() check on
exception (when getting NULL) to an assertion to detect bugs earlier
2013-07-12 00:11:58 +02:00
Victor Stinner aaa8ed8b84 Issue #18408: Fix call_exc_trace(): if the traceback is NULL, use None when
building the tuple (type, value, traceback) passed to the callback.

PyTuple_Pack() does crash if an argument is NULL.
2013-07-10 13:57:55 +02:00
Victor Stinner 0ff0f54dd4 Issue #18408: Fix call_function() of ceval.c to handle PyTuple_New() failure
(in load_args()), ex: MemoryError.
2013-07-08 22:27:42 +02:00
Brett Cannon 679ecb565b Issue #15767: back out 8a0ed9f63c6e, finishing the removal of
ModuleNotFoundError.
2013-07-04 17:51:50 -04:00
Brett Cannon b1611e2772 Issue #15767: Introduce ModuleNotFoundError, a subclass of
ImportError.

The exception is raised by import when a module could not be found.
Technically this is defined as no viable loader could be found for the
specified module. This includes ``from ... import`` statements so that
the module usage is consistent for all situations where import
couldn't find what was requested.

This should allow for the common idiom of::

  try:
    import something
  except ImportError:
    pass

to be updated to using ModuleNotFoundError and not accidentally mask
ImportError messages that should propagate (e.g. issues with a
loader).

This work was driven by the fact that the ``from ... import``
statement needed to be able to tell the difference between an
ImportError that simply couldn't find a module (and thus silence the
exception so that ceval can raise it) and an ImportError that
represented an actual problem.
2013-06-12 16:59:46 -04:00
Victor Stinner d3dfd0e433 Fix a compilater warning on Windows 64-bit
idx variable is used for a tuple indexn so use Py_ssize_t (not int).
2013-05-16 23:48:01 +02:00
Benjamin Peterson e8e14591eb rather than passing locals to the class body, just execute the class body in the proper environment 2013-05-16 14:37:25 -05:00
Benjamin Peterson e1b4cbc422 when arguments are cells clear the locals slot (backport of #17927) 2013-05-14 22:31:26 -05:00
Benjamin Peterson 159ae41da6 when an argument is a cell, set the local copy to NULL (see #17927) 2013-05-12 18:16:06 -05:00
Guido van Rossum 6832c81d5d #17927: Keep frame from referencing cell-ified arguments. 2013-05-10 08:47:42 -07:00
Antoine Pitrou 8408cea0cd Issue #17094: Clear stale thread states after fork().
Note that this is a potentially disruptive change since it may
release some system resources which would otherwise remain
perpetually alive (e.g. database connections kept in thread-local
storage).
2013-05-05 23:47:09 +02:00
Benjamin Peterson 3b0431dc60 check local class namespace before reaching for cells (closes #17853) 2013-04-30 09:41:40 -04:00
R David Murray f097f175dd Merge #17413: make sure settrace funcs get passed exception instances for 'value'.
Patch by Ingrid Cheung and Brendan McLoughlin.
2013-04-19 12:57:54 -04:00
R David Murray 3583761bcd #17413: make sure settrace funcs get passed exception instances for 'value'.
Patch by Ingrid Cheung and Brendan McLoughlin.
2013-04-19 12:56:57 -04:00
Ezio Melotti 04a29554c1 #17032: The "global" in the "NameError: global name 'x' is not defined" error message has been removed. Patch by Ram Rachum. 2013-03-03 15:12:44 +02:00
Benjamin Peterson 1ef876cd28 evaluate positional defaults before keyword-only defaults (closes #16967) 2013-02-10 09:29:59 -05:00
Benjamin Peterson 51f4616f6e revert #16672 for incorrect semantics 2013-01-23 08:38:47 -05:00
Benjamin Peterson 6f0c94df50 improve tracing performance when f_trace is NULL (closes #16672)
Patch by Xavier de Gaye.
2012-12-24 11:53:30 -06:00
Benjamin Peterson 9272279afd use error label instead of breaking eval loop (closes #16693) 2012-12-15 12:51:05 -05:00