summaryrefslogtreecommitdiffstats
path: root/Objects/genobject.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.8] closes bpo-39630: Update pointers to string literals to be const char ↵Benjamin Peterson2020-02-141-2/+2
| | | | | | | | *. (GH-18511) (cherry picked from commit 7386a70746cf9aaf2d95db75d9201fb124f085df) Co-authored-by: Andy Lester <andy@petdance.com>
* [3.8] bpo-39606: allow closing async generators that are already closed ↵Miss Islington (bot)2020-02-131-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-18475) (GH-18501) The fix for [bpo-39386](https://bugs.python.org/issue39386) attempted to make it so you couldn't reuse a agen.aclose() coroutine object. It accidentally also prevented you from calling aclose() at all on an async generator that was already closed or exhausted. This commit fixes it so we're only blocking the actually illegal cases, while allowing the legal cases. The new tests failed before this patch. Also confirmed that this fixes the test failures we were seeing in Trio with Python dev builds: https://github.com/python-trio/trio/pull/1396 https://bugs.python.org/issue39606 (cherry picked from commit 925dc7fb1d0db85dc137afa4cd14211bf0d67414) Co-authored-by: Nathaniel J. Smith <njs@pobox.com> https://bugs.python.org/issue39606 Automerge-Triggered-By: @njsmith
* bpo-39386: Prevent double awaiting of async iterator (GH-18081)Miss Islington (bot)2020-01-201-4/+12
| | | | | (cherry picked from commit a96e06db77dcbd3433d39761ddb4615d7d96284a) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-35409: Ignore GeneratorExit in async_gen_athrow_throw (GH-14755)Miss Islington (bot)2019-11-191-0/+11
| | | | | | | | Ignore `GeneratorExit` exceptions when throwing an exception into the `aclose` coroutine of an asynchronous generator. https://bugs.python.org/issue35409 (cherry picked from commit 8e0de2a4808d7c2f4adedabff89ee64e0338790a) Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
* bpo-30773: Fix ag_running; prohibit running athrow/asend/aclose in parallel ↵Miss Islington (bot)2019-09-301-2/+34
| | | | | | | (GH-7468) (#16486) (cherry picked from commit fc4a044a3c54ce21e9ed150f7d769fb479d34c49) Co-authored-by: Yury Selivanov <yury@magic.io>
* bpo-38013: make async_generator_athrow object tolerant to throwing ↵Miss Islington (bot)2019-09-171-5/+0
| | | | | | | | | | | | | exceptions (GH-16070) Even when the helper is not started yet. This behavior follows conventional generator one. There is no reason for `async_generator_athrow` to handle `gen.throw()` differently. https://bugs.python.org/issue38013 (cherry picked from commit c275312a6284bd319ea33c9abd7e15c230eca43f) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-7/+7
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-32388: Remove cross-version binary compatibility requirement in tp_flags ↵Antoine Pitrou2019-05-291-6/+3
| | | | | | | | (GH-4944) It is now allowed to add new fields at the end of the PyTypeObject struct without having to allocate a dedicated compatibility flag in tp_flags. This will reduce the risk of running out of bits in the 32-bit tp_flags value.
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Serhiy Storchaka2018-11-271-6/+6
| | | Fix also return type for few other functions (clear, releasebuffer).
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-211-0/+1
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35269: Fix a possible segfault involving a newly-created coroutine ↵Zackery Spytz2018-11-181-1/+1
| | | | | | | | | | | (GH-10585) coro->cr_origin wasn't initialized if compute_cr_origin() failed in PyCoro_New(), which would cause a crash during the coroutine's deallocation. https://bugs.python.org/issue35269
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* closes bpo-34493: Objects/genobject.c: Add missing NULL check to ↵Alexey Izbyshev2018-08-251-0/+3
| | | | compute_cr_origin() (GH-8911)
* bpo-33786: Fix asynchronous generators to handle GeneratorExit in athrow() ↵Yury Selivanov2018-06-081-8/+7
| | | | (GH-7467)
* bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter ↵Serhiy Storchaka2018-02-221-6/+4
| | | | | | | | | to compiler. (GH-5006) Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Antoine Pitrou <antoine@python.org>
* bpo-32703: Fix coroutine resource warning in case where there's an error ↵Yury Selivanov2018-01-291-6/+7
| | | | | (GH-5410) The commit removes one unnecessary "if" clause in genobject.c. That "if" clause was masking un-awaited coroutines warnings just to make writing unittests more convenient.
* bpo-32670: Enforce PEP 479. (#5327)Yury Selivanov2018-01-261-50/+8
|
* bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka2018-01-251-12/+9
| | | | | (GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
* bpo-32591: Add native coroutine origin tracking (#5250)Nathaniel J. Smith2018-01-211-4/+57
| | | | | | * Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth * Use coroutine origin information in the unawaited coroutine warning * Stop using set_coroutine_wrapper in asyncio debug mode * In BaseEventLoop.set_debug, enable debugging in the correct thread
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-4/+4
| | | | (#4370)
* Move exc state to generator. Fixes bpo-25612 (#1773)Mark Shannon2017-10-221-11/+35
| | | Move exception state information from frame objects to coroutine (generator/thread) object where it belongs.
* bpo-31709: Drop support for asynchronous __aiter__. (#3903)Yury Selivanov2017-10-061-94/+0
|
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+1
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Fix wrapping into StopIteration of return values in generators and ↵Yury Selivanov2017-03-121-2/+1
| | | | coroutines (#644)
* 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-091-14/+48
|
* Merge 3.5Yury Selivanov2016-11-091-2/+2
|\
| * genobject: Remove unnecessary tp_free slots from aiter_wrapper and coro_wrapperYury Selivanov2016-11-091-2/+2
| |
* | 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 #23996: Added _PyGen_SetStopIterationValue for safe raisingSerhiy Storchaka2016-11-061-10/+50
| | | | | | | | | | 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-091-46/+986
| |
* | Add NULL check for gen->gi_code in gen_send_ex()Christian Heimes2016-09-081-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
|\ \ | |/
| * supress coroutine warning when an exception is pending (#27968)Benjamin Peterson2016-09-071-12/+15
| |
* | Avoid calling functions with an empty string as format stringVictor Stinner2016-09-061-1/+1
| | | | | | | | Directly pass NULL rather than an empty string.
* | merge 3.5 (#27812)Benjamin Peterson2016-09-051-1/+4
|\ \ | |/
| * clear out f_gen during generator finalization (closes #27812)Benjamin Peterson2016-09-051-1/+4
| | | | | | | | Patch from Armin Rigo.
* | merge 3.5 (closes #27811)Benjamin Peterson2016-09-051-12/+13
|\ \ | |/