From 6253f83b0a2d261024cd5ef84d2e36fe4f4f1f3d Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Wed, 12 Jul 2000 12:56:19 +0000 Subject: change abstract size functions PySequence_Size &c. add macros for backwards compatibility with C source --- Include/abstract.h | 18 ++++++++++++------ Objects/abstract.c | 16 ++++++++-------- Objects/object.c | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Include/abstract.h b/Include/abstract.h index 6b96adf..d1a1db3 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -381,11 +381,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ equivalent to the Python expression: type(o). */ - DL_IMPORT(int) PyObject_Length(PyObject *o); + DL_IMPORT(int) PyObject_Size(PyObject *o); + +#define PyObject_Length(O) PyObject_Size((O)) /* - Return the length of object o. If the object, o, provides - both sequence and mapping protocols, the sequence length is + Return the size of object o. If the object, o, provides + both sequence and mapping protocols, the sequence size is returned. On error, -1 is returned. This is the equivalent to the Python expression: len(o). @@ -681,10 +683,12 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ */ - DL_IMPORT(int) PySequence_Length(PyObject *o); + DL_IMPORT(int) PySequence_Size(PyObject *o); + +#define PySequence_Length(O) PySequence_Size((O)) /* - Return the length of sequence object o, or -1 on failure. + Return the size of sequence object o, or -1 on failure. */ @@ -833,7 +837,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ This function always succeeds. */ - DL_IMPORT(int) PyMapping_Length(PyObject *o); + DL_IMPORT(int) PyMapping_Size(PyObject *o); + +#define PyMapping_Length(O) PyMapping_Size((O)) /* Returns the number of keys in object o on success, and -1 on diff --git a/Objects/abstract.c b/Objects/abstract.c index 5717815..2c7c307 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -62,7 +62,7 @@ PyObject_Type(PyObject *o) } int -PyObject_Length(PyObject *o) +PyObject_Size(PyObject *o) { PySequenceMethods *m; @@ -75,7 +75,7 @@ PyObject_Length(PyObject *o) if (m && m->sq_length) return m->sq_length(o); - return PyMapping_Length(o); + return PyMapping_Size(o); } PyObject * @@ -803,7 +803,7 @@ PySequence_Check(PyObject *s) } int -PySequence_Length(PyObject *s) +PySequence_Size(PyObject *s) { PySequenceMethods *m; @@ -1036,7 +1036,7 @@ PySequence_Tuple(PyObject *v) if (m && m->sq_item) { int i; PyObject *t; - int n = PySequence_Length(v); + int n = PySequence_Size(v); if (n < 0) return NULL; t = PyTuple_New(n); @@ -1087,7 +1087,7 @@ PySequence_List(PyObject *v) if (m && m->sq_item) { int i; PyObject *l; - int n = PySequence_Length(v); + int n = PySequence_Size(v); if (n < 0) return NULL; l = PyList_New(n); @@ -1152,7 +1152,7 @@ PySequence_Count(PyObject *s, PyObject *o) return -1; } - l = PySequence_Length(s); + l = PySequence_Size(s); if (l < 0) return -1; @@ -1232,7 +1232,7 @@ PySequence_Index(PyObject *s, PyObject *o) return -1; } - l = PySequence_Length(s); + l = PySequence_Size(s); if (l < 0) return -1; @@ -1261,7 +1261,7 @@ PyMapping_Check(PyObject *o) } int -PyMapping_Length(PyObject *o) +PyMapping_Size(PyObject *o) { PyMappingMethods *m; diff --git a/Objects/object.c b/Objects/object.c index 9194c90..0c50175 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -958,7 +958,7 @@ PyTypeObject *_Py_cobject_hack = &PyCObject_Type; /* Hack to force loading of abstract.o */ -int (*_Py_abstract_hack)(PyObject *) = &PyObject_Length; +int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size; /* Python's malloc wrappers (see mymalloc.h) */ -- cgit v0.12 pandable section, hidden by defau...Miss Islington (bot)2023-06-071-1/+11 * [3.12] GH-95088: Clarify rules for parsing an item key for format strings (GH...Miss Islington (bot)2023-06-071-1/+3 * [3.12] `typing.NewType` docs: the future performance improvements are now in ...Miss Islington (bot)2023-06-071-3/+7 * [3.12] gh-105286: Further improvements to `typing.py` docstrings (GH-105363) ...Miss Islington (bot)2023-06-071-25/+43 * Merge branch '3.12' of https://github.com/python/cpython into 3.12Thomas Wouters2023-06-0613-83/+53 |\ | * gh-92658: Fix typo in docs and tests for `HV_GUID_PARENT` (GH-105267)Miss Islington (bot)2023-06-062-2/+2 | * [3.12] sliding_window() recipe: Raise ValueError for non-positive window siz...Miss Islington (bot)2023-06-061-3/+27 | * [3.12] gh-94172: Update keyfile removal documentation (GH-105392) (#105402)Miss Islington (bot)2023-06-065-51/+7 | * [3.12] gh-102304: Fix Py_INCREF() stable ABI in debug mode (#104763) (#105352)Victor Stinner2023-06-065-27/+17 * | Post 3.12.0b2Thomas Wouters2023-06-061-1/+1 * | Python 3.12.0b2v3.12.0b2Thomas Wouters2023-06-0654-234/+1207 |/ * [3.12] GH-105162: Account for `INSTRUMENTED_RESUME` in gen.close/throw. (GH-1...Miss Islington (bot)2023-06-063-3/+52 * [3.12] gh-104411: Update test_getint for Tcl 9.0 (GH-104412) (#105356)Miss Islington (bot)2023-06-061-1/+4 * [3.12] gh-104399: Use newer libtommath APIs when necessary (GH-104407) (#105343)Miss Islington (bot)2023-06-062-2/+25 * [3.12] gh-102304: doc: Add links to Stable ABI and Limited C API (#105345) (#...Victor Stinner2023-06-0616-42/+53 * [3.12] gh-105259: Ensure we don't show newline characters for trailing NEWLIN...Miss Islington (bot)2023-06-065-5/+17 * [3.12] gh-90005: Don't link with libbsd if not needed (#105236) (#105360)Erlend E. Aasland2023-06-063-5/+9 * [3.12] gh-105324: Fix tokenize module main function for stdin (GH-105325) (#1...Miss Islington (bot)2023-06-052-2/+3 * [3.12] gh-89412: Add missing attributes (added in 3.10) to traceback module d...Miss Islington (bot)2023-06-053-2/+18 * [3.12] gh-97908: CAPI docs: Remove repeated struct names from member docs (GH...Miss Islington (bot)2023-06-052-8/+23 * [3.12] What's New in 3.12: List 'Improved Modules' alphabetically (GH-105315)...Hugo van Kemenade2023-06-051-107/+107 * [3.12] Clarify that error messages are better with PEP 701 (GH-105150) (#105169)Miss Islington (bot)2023-06-051-0/+25 * [3.12] gh-105286: Improve `typing.py` docstrings (#105287) (#105319)Alex Waygood2023-06-051-220/+253 * [3.12] gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always eva...Miss Islington (bot)2023-06-053-8/+38 * [3.12] gh-105237: Allow calling `issubclass(X, typing.Protocol)` again (GH-10...Miss Islington (bot)2023-06-053-0/+65 * [3.12] gh-105164: Detect annotations inside match blocks (GH-105177) (#105313)Miss Islington (bot)2023-06-053-0/+123 * [3.12] gh-98963: Restore the ability to have a dict-less property. (GH-105262...Miss Islington (bot)2023-06-053-13/+97 * [3.12] gh-104882: Docs: fix description of relationship between `socket.getbl...Miss Islington (bot)2023-06-041-1/+1 * [3.12] Fix typo in Python 3.12 What's New (GH-105278) (#105282)Miss Islington (bot)2023-06-041-2/+2 * [3.12] gh-104690 Disallow thread creation and fork at interpreter finalizatio...Miss Islington (bot)2023-06-048-30/+97 * [3.12] gh-89415: Mention new `IP_*` constants in `socket` module in the docs ...Miss Islington (bot)2023-06-031-1/+2 * [3.12] gh-105080: Fixed inconsistent signature on derived classes (GH-105217)...Miss Islington (bot)2023-06-023-11/+31 * [3.12] gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static...Miss Islington (bot)2023-06-021-1/+3 * [3.12] gh-102778: update documentation of PyErr_PrintEx and traceback.print_l...Miss Islington (bot)2023-06-022-7/+11 * [3.12] gh-105194: Fix format specifier escaped characters in f-strings (GH-10...Miss Islington (bot)2023-06-026-2/+34 * [3.12] gh-105184: document that marshal functions can fail and need to be che...Miss Islington (bot)2023-06-022-0/+8 * [3.12] gh-104799: Default missing lists in AST to the empty list (GH-104834) ...Miss Islington (bot)2023-06-024-239/+400 * [3.12] gh-104614: Make Sure ob_type is Always Set Correctly by PyType_Ready()...Miss Islington (bot)2023-06-014-17/+128 * [3.12] gh-104341: Call _PyEval_ReleaseLock() with NULL When Finalizing the Cu...Miss Islington (bot)2023-06-014-9/+46 * [3.12] gh-105020: Share tp_bases and tp_mro Between Interpreters For All Stat...Miss Islington (bot)2023-06-017-26462/+26544 * [3.12] GH-89886: Bump to GNU Autoconf v2.71 (#104925) (#105207)Erlend E. Aasland2023-06-018-7426/+10591 * [3.12] gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174) ...Miss Islington (bot)2023-06-0113-18/+8794 * [3.12] gh-89886: Rely on HAVE_SYS_TIME_H (GH-105058) (#105192)Miss Islington (bot)2023-06-015-19/+10 * gh-105146: Update links at end of Windows installer (uninstall/repair) (GH-10...Miss Islington (bot)2023-05-31