summaryrefslogtreecommitdiff
path: root/Objects/genobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-2/+1
| | | | possible. Patch is writen with Coccinelle.
* Backed out changeset 99c34e47348bVictor Stinner2016-12-091-1/+1
| | | | The change broke test_gdb.
* Inline PyEval_EvalFrameEx() in callersVictor Stinner2016-12-091-1/+1
| | | | | | | | The PEP 523 modified PyEval_EvalFrameEx(): it's now an indirection to interp->eval_frame(). Inline the call in performance critical code. Leave PyEval_EvalFrame() unchanged, this function is only kept for backward compatibility.
* Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner2016-12-051-1/+1
| | | | | | | | | | | Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue.
* Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-2/+2
| | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* Replace PyObject_CallFunction() with fastcallVictor Stinner2016-12-011-1/+1
| | | | | | | | | | | | | | | | | Replace PyObject_CallFunction(func, "O", arg) and PyObject_CallFunction(func, "O", arg, NULL) with _PyObject_CallArg1(func, arg) Replace PyObject_CallFunction(func, NULL) with _PyObject_CallNoArg(func) _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack.
* Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-2/+2
| | | | | | | | | | | | | | * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
* Fix _PyGen_yf()Victor Stinner2016-11-241-0/+9
| | | | | | | | Issue #28782: Fix a bug in the implementation ``yield from`` when checking if the next instruction is YIELD_FROM. Regression introduced by WORDCODE (issue #26647). Reviewed by Serhiy Storchaka and Yury Selivanov.
* Issue #28721: Fix asynchronous generators aclose() and athrow()Yury Selivanov2016-11-161-3/+11
|
* Issue #28003: Make WrappedVal, ASend and AThrow GC typesYury Selivanov2016-11-081-14/+48
|
* Merge 3.5Yury Selivanov2016-11-081-60/+954
|\
| * Issue #23996: Added _PyGen_SetStopIterationValue for safe raisingSerhiy Storchaka2016-11-061-21/+51
| |\ | | | | | | | | | | | | StopIteration with value. More safely handle non-normalized exceptions in -_PyGen_FetchStopIterationValue.
| * | Issue #28410: Added _PyErr_FormatFromCause() -- the helper for raisingSerhiy Storchaka2016-10-211-30/+2
| | | | | | | | | | | | | | | | | | | | | | | | new exception with setting current exception as __cause__. _PyErr_FormatFromCause(exception, format, args...) is equivalent to Python raise exception(format % args) from sys.exc_info()[1]
| * | Issue #27129: Replaced wordcode related magic constants with macros.Serhiy Storchaka2016-09-111-2/+2
| | |
| * | Issue #28003: Implement PEP 525 -- Asynchronous Generators.Yury Selivanov2016-09-081-46/+986
| | |
| * | Add NULL check for gen->gi_code in gen_send_ex()Christian Heimes2016-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _PyGen_Finalize() checks that gen->gi_code is not NULL before it accesses the flags of the code object. This means that the flag could be NULL. It passes down the generatore to gen_close() and gen_send_ex(). gen_send_ex() did not check for gen->gi_code != NULL. CID 1297900
| * | merge 3.5 (#27968)Benjamin Peterson2016-09-071-12/+15
| |\ \
| * | | Avoid calling functions with an empty string as format stringVictor Stinner2016-09-051-1/+1
| | | | | | | | | | | | | | | | Directly pass NULL rather than an empty string.
| * | | merge 3.5 (#27812)Benjamin Peterson2016-09-051-13/+5
| |\ \ \
| | * \ \ merge 3.5 (closes #27811)Benjamin Peterson2016-09-051-12/+13
| | |\ \ \
| | * \ \ \ Merge 3.5 (issue #27243)Yury Selivanov2016-06-091-13/+5
| | |\ \ \ \
| | | * | | | Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.Serhiy Storchaka2016-05-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Demur Rumed.
| | | * | | | Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-11/+3
| | | |\ \ \ \
| | | | * \ \ \ Merge 3.5 (issue #25888)Yury Selivanov2016-03-021-11/+3
| | | | |\ \ \ \ | | | |/ / / / /
| | | | * | | | Merge 3.5 (issue #25887)Yury Selivanov2016-02-131-11/+3
| | | | |\ \ \ \
| | | | | * | | | Issue #26136: Upgrade the generator_stop warning to DeprecationWarningMartin Panter2016-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Anish Shah.
| | | | | * | | | Issue #20440: Cleaning up the code by using Py_SETREF.Serhiy Storchaka2016-01-051-10/+2
| | | | | | | | |
* | | | | | | | | genobject: Remove unnecessary tp_free slots from aiter_wrapper and coro_wrapperYury Selivanov2016-11-081-2/+2
| |_|_|_|_|_|_|/ |/| | | | | | |
* | | | | | | | Issue #23996: Added _PyGen_SetStopIterationValue for safe raisingSerhiy Storchaka2016-11-061-10/+50
| |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | StopIteration with value. More safely handle non-normalized exceptions in -_PyGen_FetchStopIterationValue.
* | | | | | | supress coroutine warning when an exception is pending (#27968)Benjamin Peterson2016-09-071-12/+15
|/ / / / / /
* | | | | | clear out f_gen during generator finalization (closes #27812)Benjamin Peterson2016-09-051-1/+4
| |_|_|_|/ |/| | | | | | | | | | | | | | Patch from Armin Rigo.
* | | | | do not allow _PyGen_Finalize to fail (closes #27811)Benjamin Peterson2016-09-051-12/+13
|/ / / / | | | | | | | | | | | | Patch from Armin Rigo.
* | | | Issue #27243: Fix __aiter__ protocolYury Selivanov2016-06-091-0/+94
|/ / /
* | | coroutines: Error when awaiting on coroutine that's being awaitedYury Selivanov2016-03-021-6/+6
|/ / | | | | | | Issue #25888
* | Issue #25887: Raise a RuntimeError when a coroutine is awaited more than once.Yury Selivanov2016-02-131-12/+21
|/
* Issue #24450: Add gi_yieldfrom to generators; cr_await to coroutines.Yury Selivanov2015-07-031-0/+22
| | | | Patch by Benno Leslie and Yury Selivanov.
* Issue #24439: Improve PEP 492 related docs.Yury Selivanov2015-06-241-5/+5
| | | | Patch by Martin Panter.
* Issue #24400: Introduce a distinct type for 'async def' coroutines.Yury Selivanov2015-06-221-57/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of changes: 1. Coroutines now have a distinct, separate from generators type at the C level: PyGen_Type, and a new typedef PyCoroObject. PyCoroObject shares the initial segment of struct layout with PyGenObject, making it possible to reuse existing generators machinery. The new type is exposed as 'types.CoroutineType'. As a consequence of having a new type, CO_GENERATOR flag is no longer applied to coroutines. 2. Having a separate type for coroutines made it possible to add an __await__ method to the type. Although it is not used by the interpreter (see details on that below), it makes coroutines naturally (without using __instancecheck__) conform to collections.abc.Coroutine and collections.abc.Awaitable ABCs. [The __instancecheck__ is still used for generator-based coroutines, as we don't want to add __await__ for generators.] 3. Add new opcode: GET_YIELD_FROM_ITER. The opcode is needed to allow passing native coroutines to the YIELD_FROM opcode. Before this change, 'yield from o' expression was compiled to: (o) GET_ITER LOAD_CONST YIELD_FROM Now, we use GET_YIELD_FROM_ITER instead of GET_ITER. The reason for adding a new opcode is that GET_ITER is used in some contexts (such as 'for .. in' loops) where passing a coroutine object is invalid. 4. Add two new introspection functions to the inspec module: getcoroutinestate(c) and getcoroutinelocals(c). 5. inspect.iscoroutine(o) is updated to test if 'o' is a native coroutine object. Before this commit it used abc.Coroutine, and it was requested to update inspect.isgenerator(o) to use abc.Generator; it was decided, however, that inspect functions should really be tailored for checking for native types. 6. sys.set_coroutine_wrapper(w) API is updated to work with only native coroutines. Since types.coroutine decorator supports any type of callables now, it would be confusing that it does not work for all types of coroutines. 7. Exceptions logic in generators C implementation was updated to raise clearer messages for coroutines: Before: TypeError("generator raised StopIteration") After: TypeError("coroutine raised StopIteration")
* Issue 24017: Drop getawaitablefunc and friends in favor of unaryfunc.Yury Selivanov2015-05-281-1/+1
|
* Issue 24237: Raise PendingDeprecationWarning per PEP 479Yury Selivanov2015-05-221-3/+20
| | | | | | | | | Raise PendingDeprecationWarning when generator raises StopIteration and no __future__ import is used. Fix offenders in the stdlib and tests. See also issue 22906. Thanks to Nick Coghlan and Berker Peksag for reviews.
* Issue #24257: Fixed incorrect uses of PyObject_IsInstance().Serhiy Storchaka2015-05-221-23/+196
|\ | | | | | | | | Fixed segmentation fault in sqlite3.Row constructor with faked cursor type. Fixed system error in the comparison of faked types.SimpleNamespace.
| * Fix warnings for gen_get_iter()Yury Selivanov2015-05-111-1/+1
| |
| * PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-111-5/+97
| |
| * Issue #22906: Do incref before SetCause/SetContextYury Selivanov2015-05-101-1/+1
| |
| * Issue 22906: Increment refcount after PyException_SetContextYury Selivanov2015-05-091-0/+1
| |
| * PEP 479: Change StopIteration handling inside generators.Yury Selivanov2015-05-091-0/+24
| | | | | | | | Closes issue #22906.
| * Issue #23996: Avoid a crash when a delegated generator raises an ↵Antoine Pitrou2015-04-261-5/+22
| |\ | | | | | | | | | unnormalized StopIteration exception. Patch by Stefan Behnel.
| * | Issue #21938: simplify gen_iternext()Antoine Pitrou2014-07-081-5/+1
| | |
| * | Issue #21205: Add a new ``__qualname__`` attribute to generator, the qualifiedVictor Stinner2014-06-161-15/+75
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Issue #24257: Fixed incorrect uses of PyObject_IsInstance().Serhiy Storchaka2015-05-221-3/+2
| |/ |/| | | | | | | Fixed segmentation fault in sqlite3.Row constructor with faked cursor type. Fixed system error in the comparison of faked types.SimpleNamespace.