summaryrefslogtreecommitdiffstats
path: root/Objects/iterobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-101892: Fix `SystemError` when a callable iterator call exhausts the ↵Raj2023-03-041-2/+2
| | | | | iterator (#101896) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` when ↵Ionite2023-02-241-6/+16
| | | | internal access of `builtins.__dict__` exhausts the iterator (#101769)
* gh-99300: Use Py_NewRef() in Objects/ directory (#99335)Victor Stinner2022-11-101-10/+5
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
* gh-96348: Deprecate the 3-arg signature of coroutine.throw and ↵Ofey Chan2022-09-301-2/+7
| | | | generator.throw (GH-96428)
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-1/+2
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-1/+1
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* bpo-44963: Implement send() and throw() methods for anext_awaitable objects ↵Pablo Galindo Salgado2021-09-071-22/+96
| | | | | (GH-27955) Co-authored-by: Yury Selivanov <yury@edgedb.com>
* bpo-43751: Fix anext() bug where it erroneously returned None (GH-25238)Dennis Sweeney2021-04-111-1/+46
|
* bpo-43770: _PyTypes_Init() inits _PyAnextAwaitable_Type (GH-25266)Victor Stinner2021-04-081-2/+2
| | | | * Rename PyAnextAwaitable_Type to _PyAnextAwaitable_Type. * Expose the type in the internal C API.
* bpo-31861: Fix possible crash in PyAnextAwaitable_New (GH-25005)Pablo Galindo2021-03-241-1/+5
|
* bpo-31861: Add aiter and anext to builtins (#23847)Joshua Bronson2021-03-231-2/+90
| | | | | | Co-authored-by: jab <jab@users.noreply.github.com> Co-authored-by: Daniel Pope <mauve@mauveweb.co.uk> Co-authored-by: Justin Wang <justin39@gmail.com>
* bpo-40268: Remove unused pycore_pymem.h includes (GH-19531)Victor Stinner2020-04-151-1/+0
|
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-1/+0
|
* bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)Hai Shi2020-01-301-2/+2
| | | Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-4/+4
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-35444: Unify and optimize the helper for getting a builtin object. ↵Serhiy Storchaka2018-12-111-4/+6
| | | | | | | | (GH-11047) This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
* 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-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-2/+2
| | | | | | | | | | | | | | 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 pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | * 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".
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-3/+3
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+2
| | | | | | | * 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).
* Rename _PyObject_FastCall() to _PyObject_FastCallDict()Victor Stinner2016-08-221-1/+1
| | | | | | | | Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict()
* calliter_iternext() now uses fast callVictor Stinner2016-08-191-19/+21
| | | | | | | Issue #27128: calliter_iternext() now calls _PyObject_FastCall() to avoid a temporary empty tuple. Cleanup also the code to reduce the indentation level.
* Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-1/+1
| | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
* Issue #23985: Fixed integer overflow in iterator object. Patch bySerhiy Storchaka2015-05-211-0/+5
|\ | | | | | | Clement Rouault.
| * Issue #23985: Fixed integer overflow in iterator object. Patch bySerhiy Storchaka2015-05-211-0/+5
| | | | | | | | Clement Rouault.
* | Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka2015-03-181-1/+1
|/
* Close #17932: Fix an integer overflow issue on Windows 64-bit in iterators:Victor Stinner2013-06-041-1/+1
| | | | change the C type of seqiterobject.it_index from long to Py_ssize_t.
* Fixed a missing incref introduced by a7ec0a1b0f7cArmin Ronacher2012-10-061-1/+1
|
* Issue #16148: implemented PEP 424Armin Ronacher2012-10-061-3/+8
|
* Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in ↵Antoine Pitrou2012-04-041-17/+4
| | | | the stable ABI.
* Issue #14288: Serialization support for builtin iterators.Kristján Valur Jónsson2012-04-031-1/+59
|
* Fix nit (sentinel on lhs of comparison).Raymond Hettinger2010-08-071-3/+1
|
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-164/+164
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Issue #1717: rename tp_compare to tp_reserved. I'll change theMark Dickinson2009-02-021-2/+2
| | | | | type of tp_compare in a separate commit, for ease of reversion should things go wrong.
* Move itertools izip() code to builtins as zip(). Complete the renaming.Raymond Hettinger2008-03-131-169/+0
|
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.Christian Heimes2007-12-191-1/+1
|
* Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases ↵Christian Heimes2007-12-021-2/+2
| | | | in intobject.h
* Added all PyTypeObjects to the appropriate header files.Christian Heimes2007-11-291-3/+3
| | | | Before the patch a lot of internal types weren't available in the header files. The patch exposes the new iterators, views and some other types to all C modules. I've also renamed some of the types and tp_names.
* Added view and iterator types to collections / _abcollChristian Heimes2007-11-281-1/+1
| | | | I've also renamed several of the iterators to keep a consistent naming schema.
* Merged revisions 56467-56482 via svnmerge fromMartin v. Löwis2007-07-211-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ................ r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines Merged revisions 56466-56476 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines PEP 3123: Provide forward compatibility with Python 3.0, while keeping backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT. ........ ................ r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines PEP 3123: Use proper C inheritance for PyObject. ................ r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines Add longintrepr.h to Python.h, so that the compiler can see that PyFalse is really some kind of PyObject*. ................ r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines Qualify SHIFT, MASK, BASE. ................ r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines Correctly refer to _ob_next. ................
* Remove bogus INCREF of ziptuple: it is aMartin v. Löwis2007-02-061-1/+0
| | | | freshly-allocated tuple object.
* The daily ritual: fix C89 violations.Guido van Rossum2006-08-261-2/+4
|
* SF patch 1546297 (with some tweaks):Guido van Rossum2006-08-251-0/+171
| | | | | Create a real zip iterator object; not using itertools.izip (Brian Holmes).
* Merge p3yk branch with the trunk up to revision 45595. This breaks a fairThomas Wouters2006-04-211-9/+5
| | | | | | | | | | | | | | | | | | | | number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-1/+1
| | | | Convert Py_ssize_t using PyInt_FromSsize_t
* Merge ssize_t branch.Martin v. Löwis2006-02-151-1/+1
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-2/+2
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-20/+11
|