Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit664aa94

Browse files
Document Py_ssize_t. (GH-92512)
It fixes 252 errors from a Sphinx nitpicky run (sphinx-build -n). Butthere's 8182 errors left.Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
1 parent059b5ba commit664aa94

File tree

10 files changed

+31
-24
lines changed

10 files changed

+31
-24
lines changed

‎Doc/c-api/arg.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Numbers
249249
Convert a Python integer to a C:c:type:`unsigned long long`
250250
without overflow checking.
251251

252-
``n`` (:class:`int`) [Py_ssize_t]
252+
``n`` (:class:`int`) [:c:type:`Py_ssize_t`]
253253
Convert a Python integer to a C:c:type:`Py_ssize_t`.
254254

255255
``c`` (:class:`bytes` or:class:`bytearray` of length 1) [char]
@@ -576,7 +576,7 @@ Building values
576576
``K`` (:class:`int`) [unsigned long long]
577577
Convert a C :c:type:`unsigned long long` to a Python integer object.
578578
579-
``n`` (:class:`int`) [Py_ssize_t]
579+
``n`` (:class:`int`) [:c:type:`Py_ssize_t`]
580580
Convert a C :c:type:`Py_ssize_t` to a Python integer.
581581
582582
``c`` (:class:`bytes` of length 1) [char]

‎Doc/c-api/bytes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ called with a non-bytes parameter.
8484
|:attr:`%lu`| unsigned long| Equivalent to|
8585
||| ``printf("%lu")``. [1]_|
8686
+-------------------+---------------+--------------------------------+
87-
|:attr:`%zd`|Py_ssize_t| Equivalent to|
88-
||| ``printf("%zd")``. [1]_|
87+
|:attr:`%zd`|:c:type:`\| Equivalent to|
88+
||Py_ssize_t`| ``printf("%zd")``. [1]_|
8989
+-------------------+---------------+--------------------------------+
9090
|:attr:`%zu`| size_t| Equivalent to|
9191
||| ``printf("%zu")``. [1]_|

‎Doc/c-api/intro.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,13 @@ data attributes of a new object type, and another is used to describe the value
537537
of a complex number. These will be discussed together with the functions that
538538
use them.
539539

540+
..c:type:: Py_ssize_t
541+
542+
A signed integral type such that ``sizeof(Py_ssize_t) == sizeof(size_t)``.
543+
C99 doesn't define such a thing directly (size_t is an unsigned integral type).
544+
See:pep:`353` for details. ``PY_SSIZE_T_MAX`` is the largest positive value
545+
of type:c:type:`Py_ssize_t`.
546+
540547

541548
.. _api-exceptions:
542549

‎Doc/c-api/number.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ Number Protocol
273273
274274
..c:function:: Py_ssize_tPyNumber_AsSsize_t(PyObject *o, PyObject *exc)
275275
276-
Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an
276+
Returns *o* converted to a:c:type:`Py_ssize_t` value if *o* can be interpreted as an
277277
integer. If the call fails, an exception is raised and ``-1`` is returned.
278278
279279
If *o* can be converted to a Python int but the attempt to
280-
convert to a Py_ssize_t value would raise an:exc:`OverflowError`, then the
280+
convert to a:c:type:`Py_ssize_t` value would raise an:exc:`OverflowError`, then the
281281
*exc* argument is the type of exception that will be raised (usually
282282
:exc:`IndexError` or:exc:`OverflowError`). If *exc* is ``NULL``, then the
283283
exception is cleared and the value is clipped to ``PY_SSIZE_T_MIN`` for a negative

‎Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Object Protocol
258258
259259
..versionchanged::3.2
260260
The return type is now Py_hash_t. This is a signed integer the same size
261-
as Py_ssize_t.
261+
as:c:type:`Py_ssize_t`.
262262
263263
264264
..c:function:: Py_hash_tPyObject_HashNotImplemented(PyObject *o)

‎Doc/c-api/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ accessible to C code. They all work with the current interpreter thread's
348348
leaks.)
349349
350350
Note that ``#`` format characters should always be treated as
351-
``Py_ssize_t``, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
351+
:c:type:`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
352352
353353
:func:`sys.audit` performs the same function from Python code.
354354
355355
..versionadded::3.8
356356
357357
..versionchanged::3.8.2
358358
359-
Require``Py_ssize_t`` for ``#`` format characters. Previously, an
359+
Require:c:type:`Py_ssize_t` for ``#`` format characters. Previously, an
360360
unavoidable deprecation warning was raised.
361361
362362

‎Doc/c-api/typeobj.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ Quick Reference
4343
+================================================+===================================+===================+===+===+===+===+
4444
| <R>:c:member:`~PyTypeObject.tp_name`| const char *| __name__| X| X|||
4545
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
46-
|:c:member:`~PyTypeObject.tp_basicsize`| Py_ssize_t|| X| X|| X|
46+
|:c:member:`~PyTypeObject.tp_basicsize`|:c:type:`Py_ssize_t`|| X| X|| X|
4747
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
48-
|:c:member:`~PyTypeObject.tp_itemsize`| Py_ssize_t||| X|| X|
48+
|:c:member:`~PyTypeObject.tp_itemsize`|:c:type:`Py_ssize_t`||| X|| X|
4949
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
5050
|:c:member:`~PyTypeObject.tp_dealloc`|:c:type:`destructor`|| X| X|| X|
5151
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
52-
|:c:member:`~PyTypeObject.tp_vectorcall_offset`| Py_ssize_t||| X|| X|
52+
|:c:member:`~PyTypeObject.tp_vectorcall_offset`|:c:type:`Py_ssize_t`||| X|| X|
5353
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
5454
| (:c:member:`~PyTypeObject.tp_getattr`)|:c:type:`getattrfunc`| __getattribute__,|||| G|
5555
||| __getattr__|||||
@@ -96,7 +96,7 @@ Quick Reference
9696
||| __gt__,|||||
9797
||| __ge__|||||
9898
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
99-
|:c:member:`~PyTypeObject.tp_weaklistoffset`| Py_ssize_t||| X|| ?|
99+
|:c:member:`~PyTypeObject.tp_weaklistoffset`|:c:type:`Py_ssize_t`||| X|| ?|
100100
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
101101
|:c:member:`~PyTypeObject.tp_iter`|:c:type:`getiterfunc`| __iter__|||| X|
102102
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
@@ -117,7 +117,7 @@ Quick Reference
117117
|:c:member:`~PyTypeObject.tp_descr_set`|:c:type:`descrsetfunc`| __set__,|||| X|
118118
||| __delete__|||||
119119
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
120-
|:c:member:`~PyTypeObject.tp_dictoffset`| Py_ssize_t||| X|| ?|
120+
|:c:member:`~PyTypeObject.tp_dictoffset`|:c:type:`Py_ssize_t`||| X|| ?|
121121
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
122122
|:c:member:`~PyTypeObject.tp_init`|:c:type:`initproc`| __init__| X| X|| X|
123123
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
@@ -333,7 +333,7 @@ slot typedefs
333333
|:c:type:`allocfunc`| .. line-block::|:c:type:`PyObject` *|
334334
||||
335335
||:c:type:`PyTypeObject` *||
336-
|| Py_ssize_t||
336+
||:c:type:`Py_ssize_t`||
337337
+-----------------------------+-----------------------------+----------------------+
338338
|:c:type:`destructor`| void *| void|
339339
+-----------------------------+-----------------------------+----------------------+
@@ -405,7 +405,7 @@ slot typedefs
405405
+-----------------------------+-----------------------------+----------------------+
406406
|:c:type:`iternextfunc`|:c:type:`PyObject` *|:c:type:`PyObject` *|
407407
+-----------------------------+-----------------------------+----------------------+
408-
|:c:type:`lenfunc`|:c:type:`PyObject` *| Py_ssize_t|
408+
|:c:type:`lenfunc`|:c:type:`PyObject` *|:c:type:`Py_ssize_t`|
409409
+-----------------------------+-----------------------------+----------------------+
410410
|:c:type:`getbufferproc`| .. line-block::| int|
411411
||||
@@ -438,12 +438,12 @@ slot typedefs
438438
|:c:type:`ssizeargfunc`| .. line-block::|:c:type:`PyObject` *|
439439
||||
440440
||:c:type:`PyObject` *||
441-
|| Py_ssize_t||
441+
||:c:type:`Py_ssize_t`||
442442
+-----------------------------+-----------------------------+----------------------+
443443
|:c:type:`ssizeobjargproc`| .. line-block::| int|
444444
||||
445445
||:c:type:`PyObject` *||
446-
|| Py_ssize_t||
446+
||:c:type:`Py_ssize_t`||
447447
+-----------------------------+-----------------------------+----------------------+
448448
|:c:type:`objobjproc`| .. line-block::| int|
449449
||||

‎Doc/c-api/unicode.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,11 @@ APIs:
436436
|:attr:`%llu`| unsigned long long| Equivalent to|
437437
||| ``printf("%llu")``. [1]_|
438438
+-------------------+---------------------+----------------------------------+
439-
|:attr:`%zd`|Py_ssize_t| Equivalent to|
440-
||| ``printf("%zd")``. [1]_|
439+
|:attr:`%zd`|:c:type:`\| Equivalent to|
440+
||Py_ssize_t`| ``printf("%zd")``. [1]_|
441441
+-------------------+---------------------+----------------------------------+
442-
|:attr:`%zi`|Py_ssize_t| Equivalent to|
443-
||| ``printf("%zi")``. [1]_|
442+
|:attr:`%zi`|:c:type:`\| Equivalent to|
443+
||Py_ssize_t`| ``printf("%zi")``. [1]_|
444444
+-------------------+---------------------+----------------------------------+
445445
|:attr:`%zu`| size_t| Equivalent to|
446446
||| ``printf("%zu")``. [1]_|

‎Doc/howto/clinic.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ Here's the simplest example of a custom converter, from ``Modules/zlibmodule.c``
13471347
/*[python end generated code: output=da39a3ee5e6b4b0d input=35521e4e733823c7]*/
13481348

13491349
This block adds a converter to Argument Clinic named ``ssize_t``. Parameters
1350-
declared as ``ssize_t`` will be declared as type``Py_ssize_t``, and will
1350+
declared as ``ssize_t`` will be declared as type:c:type:`Py_ssize_t`, and will
13511351
be parsed by the ``'O&'`` format unit, which will call the
13521352
``ssize_t_converter`` converter function. ``ssize_t`` variables
13531353
automatically support default values.

‎Doc/whatsnew/3.8.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ Optimizations
14931493
first introduced in Python 3.4. It offers better performance and smaller
14941494
size compared to Protocol 3 available since Python 3.0.
14951495

1496-
* Removed one``Py_ssize_t`` member from ``PyGC_Head``. All GC tracked
1496+
* Removed one:c:type:`Py_ssize_t` member from ``PyGC_Head``. All GC tracked
14971497
objects (e.g. tuple, list, dict) size is reduced 4 or 8 bytes.
14981498
(Contributed by Inada Naoki in:issue:`33597`.)
14991499

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp