Skip to content

Commit 4624117

Browse files
Deploy preview for PR 1231 🛫
1 parent 50fb576 commit 4624117

594 files changed

Lines changed: 1441 additions & 1045 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pr-preview/pr-1231/_sources/c-api/descriptor.rst.txt

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,36 @@ Descriptor Objects
88
"Descriptors" are objects that describe some attribute of an object. They are
99
found in the dictionary of type objects.
1010

11-
.. XXX document these!
12-
1311
.. c:var:: PyTypeObject PyProperty_Type
1412
1513
The type object for the built-in descriptor types.
1614

1715

1816
.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
1917
18+
Create a new get-set descriptor for extension type *type* from the
19+
:c:type:`PyGetSetDef` structure *getset*.
20+
21+
Get-set descriptors expose attributes implemented by C getter and setter
22+
functions rather than stored directly in the instance. This is the same kind
23+
of descriptor created for entries in :c:member:`~PyTypeObject.tp_getset`, and
24+
it appears in Python as a :class:`types.GetSetDescriptorType` object.
25+
26+
On success, return a :term:`strong reference` to the descriptor. Return
27+
``NULL`` with an exception set on failure.
28+
29+
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *member)
30+
31+
Create a new member descriptor for extension type *type* from the
32+
:c:type:`PyMemberDef` structure *member*.
2033
21-
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
34+
Member descriptors expose fields in the type's C struct as Python
35+
attributes. This is the same kind of descriptor created for entries in
36+
:c:member:`~PyTypeObject.tp_members`, and it appears in Python as a
37+
:class:`types.MemberDescriptorType` object.
2238
39+
On success, return a :term:`strong reference` to the descriptor. Return
40+
``NULL`` with an exception set on failure.
2341
2442
.. c:var:: PyTypeObject PyMemberDescr_Type
2543
@@ -35,22 +53,53 @@ found in the dictionary of type objects.
3553
The type object for get/set descriptor objects created from
3654
:c:type:`PyGetSetDef` structures. These descriptors implement attributes
3755
whose value is computed by C getter and setter functions, and are used
38-
for many built-in type attributes.
56+
for many built-in type attributes. They correspond to
57+
:class:`types.GetSetDescriptorType` objects in Python.
3958
4059
4160
.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
4261
62+
Create a new method descriptor for extension type *type* from the
63+
:c:type:`PyMethodDef` structure *meth*.
64+
65+
Method descriptors expose C functions as methods on a type. This is the same
66+
kind of descriptor created for entries in
67+
:c:member:`~PyTypeObject.tp_methods`, and it appears in Python as a
68+
:class:`types.MethodDescriptorType` object.
69+
70+
On success, return a :term:`strong reference` to the descriptor. Return
71+
``NULL`` with an exception set on failure.
4372
4473
.. c:var:: PyTypeObject PyMethodDescr_Type
4574
4675
The type object for method descriptor objects created from
4776
:c:type:`PyMethodDef` structures. These descriptors expose C functions as
48-
methods on a type, and correspond to :class:`types.MemberDescriptorType`
77+
methods on a type, and correspond to :class:`types.MethodDescriptorType`
4978
objects in Python.
5079
5180
52-
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
81+
.. c:struct:: wrapperbase
82+
83+
Describes a slot wrapper used by :c:func:`PyDescr_NewWrapper`.
84+
85+
Each ``wrapperbase`` record stores the Python-visible name and metadata for a
86+
special method implemented by a type slot, together with the wrapper
87+
function used to adapt that slot to Python's calling convention.
5388
89+
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
90+
91+
Create a new wrapper descriptor for extension type *type* from the
92+
:c:struct:`wrapperbase` structure *base* and the wrapped slot function
93+
pointer
94+
*wrapped*.
95+
96+
Wrapper descriptors expose special methods implemented by type slots. This
97+
is the same kind of descriptor that CPython creates for slot-based special
98+
methods such as ``__repr__`` or ``__add__``, and it appears in Python as a
99+
:class:`types.WrapperDescriptorType` object.
100+
101+
On success, return a :term:`strong reference` to the descriptor. Return
102+
``NULL`` with an exception set on failure.
54103
55104
.. c:var:: PyTypeObject PyWrapperDescr_Type
56105
@@ -63,6 +112,16 @@ found in the dictionary of type objects.
63112
64113
.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
65114
115+
Create a new class method descriptor for extension type *type* from the
116+
:c:type:`PyMethodDef` structure *method*.
117+
118+
Class method descriptors expose C methods that receive the class rather than
119+
an instance when accessed. This is the same kind of descriptor created for
120+
``METH_CLASS`` entries in :c:member:`~PyTypeObject.tp_methods`, and it
121+
appears in Python as a :class:`types.ClassMethodDescriptorType` object.
122+
123+
On success, return a :term:`strong reference` to the descriptor. Return
124+
``NULL`` with an exception set on failure.
66125
67126
.. c:function:: int PyDescr_IsData(PyObject *descr)
68127
@@ -71,8 +130,18 @@ found in the dictionary of type objects.
71130
no error checking.
72131
73132
74-
.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
133+
.. c:function:: PyObject* PyWrapper_New(PyObject *d, PyObject *self)
134+
135+
Create a new bound wrapper object from the wrapper descriptor *d* and the
136+
instance *self*.
75137
138+
This is the bound form of a wrapper descriptor created by
139+
:c:func:`PyDescr_NewWrapper`. CPython creates these objects when a slot
140+
wrapper is accessed through an instance, and they appear in Python as
141+
:class:`types.MethodWrapperType` objects.
142+
143+
On success, return a :term:`strong reference` to the wrapper object. Return
144+
``NULL`` with an exception set on failure.
76145
77146
Built-in descriptors
78147
^^^^^^^^^^^^^^^^^^^^
@@ -92,9 +161,9 @@ Built-in descriptors
92161
.. c:var:: PyTypeObject PyClassMethodDescr_Type
93162
94163
The type object for C-level class method descriptor objects.
95-
This is the type of the descriptors created for :func:`classmethod` defined in
96-
C extension types, and is the same object as :class:`classmethod`
97-
in Python.
164+
This is the type of the descriptors created for :func:`classmethod` defined
165+
in C extension types, and corresponds to
166+
:class:`types.ClassMethodDescriptorType` objects in Python.
98167
99168
100169
.. c:function:: PyObject *PyClassMethod_New(PyObject *callable)
@@ -121,4 +190,3 @@ Built-in descriptors
121190
On success, this function returns a :term:`strong reference` to a new static
122191
method descriptor. On failure, this function returns ``NULL`` with an
123192
exception set.
124-

pr-preview/pr-1231/_sources/howto/a-conceptual-overview-of-asyncio.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The terms "coroutine function" and "coroutine object" are often conflated
115115
as coroutine.
116116
That can be confusing!
117117
In this article, coroutine specifically refers to a coroutine object, or more
118-
precisely, an instance of :data:`types.CoroutineType` (native coroutine).
118+
precisely, an instance of :class:`types.CoroutineType` (native coroutine).
119119
Note that coroutines can also exist as instances of
120120
:class:`collections.abc.Coroutine` -- a distinction that matters for type
121121
checking.

pr-preview/pr-1231/_sources/library/curses.panel.rst.txt

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ displayed. Panels can be added, moved up or down in the stack, and removed.
1818
Functions
1919
---------
2020

21+
The module :mod:`!curses.panel` defines the following exception:
22+
23+
24+
.. exception:: error
25+
26+
Exception raised when a curses panel library function returns an error.
27+
28+
2129
The module :mod:`!curses.panel` defines the following functions:
2230

2331

@@ -50,73 +58,91 @@ The module :mod:`!curses.panel` defines the following functions:
5058
Panel objects
5159
-------------
5260

53-
Panel objects, as returned by :func:`new_panel` above, are windows with a
54-
stacking order. There's always a window associated with a panel which determines
55-
the content, while the panel methods are responsible for the window's depth in
56-
the panel stack.
61+
.. raw:: html
62+
63+
<!-- Keep the old URL fragments working (see gh-89554) -->
64+
<span id='curses.panel.Panel.above'></span>
65+
<span id='curses.panel.Panel.below'></span>
66+
<span id='curses.panel.Panel.bottom'></span>
67+
<span id='curses.panel.Panel.hidden'></span>
68+
<span id='curses.panel.Panel.hide'></span>
69+
<span id='curses.panel.Panel.move'></span>
70+
<span id='curses.panel.Panel.replace'></span>
71+
<span id='curses.panel.Panel.set_userptr'></span>
72+
<span id='curses.panel.Panel.show'></span>
73+
<span id='curses.panel.Panel.top'></span>
74+
<span id='curses.panel.Panel.userptr'></span>
75+
<span id='curses.panel.Panel.window'></span>
76+
77+
.. class:: panel
78+
79+
Panel objects, as returned by :func:`new_panel` above, are windows with a
80+
stacking order. There's always a window associated with a panel which
81+
determines the content, while the panel methods are responsible for the
82+
window's depth in the panel stack.
5783

58-
Panel objects have the following methods:
84+
Panel objects have the following methods:
5985

6086

61-
.. method:: Panel.above()
87+
.. method:: panel.above()
6288

6389
Returns the panel above the current panel.
6490

6591

66-
.. method:: Panel.below()
92+
.. method:: panel.below()
6793

6894
Returns the panel below the current panel.
6995

7096

71-
.. method:: Panel.bottom()
97+
.. method:: panel.bottom()
7298

7399
Push the panel to the bottom of the stack.
74100

75101

76-
.. method:: Panel.hidden()
102+
.. method:: panel.hidden()
77103

78104
Returns ``True`` if the panel is hidden (not visible), ``False`` otherwise.
79105

80106

81-
.. method:: Panel.hide()
107+
.. method:: panel.hide()
82108

83109
Hide the panel. This does not delete the object, it just makes the window on
84110
screen invisible.
85111

86112

87-
.. method:: Panel.move(y, x)
113+
.. method:: panel.move(y, x)
88114

89115
Move the panel to the screen coordinates ``(y, x)``.
90116

91117

92-
.. method:: Panel.replace(win)
118+
.. method:: panel.replace(win)
93119

94120
Change the window associated with the panel to the window *win*.
95121

96122

97-
.. method:: Panel.set_userptr(obj)
123+
.. method:: panel.set_userptr(obj)
98124

99125
Set the panel's user pointer to *obj*. This is used to associate an arbitrary
100126
piece of data with the panel, and can be any Python object.
101127

102128

103-
.. method:: Panel.show()
129+
.. method:: panel.show()
104130

105131
Display the panel (which might have been hidden), placing it on top of
106132
the panel stack.
107133

108134

109-
.. method:: Panel.top()
135+
.. method:: panel.top()
110136

111137
Push panel to the top of the stack.
112138

113139

114-
.. method:: Panel.userptr()
140+
.. method:: panel.userptr()
115141

116142
Returns the user pointer for the panel. This might be any Python object.
117143

118144

119-
.. method:: Panel.window()
145+
.. method:: panel.window()
120146

121147
Returns the window object associated with the panel.
122148

pr-preview/pr-1231/_sources/library/stdtypes.rst.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,11 @@ category.
17201720
| | :meth:`str.strip` | :meth:`bytes.strip` |
17211721
| +--------------------+----------------------+----------------------+----------------------------+
17221722
| | :meth:`str.lstrip` | :meth:`str.rstrip` | :meth:`bytes.lstrip` | :meth:`bytes.rstrip` |
1723-
+--------------------------+--------------------+----------------------+----------------------+----------------------------+
1723+
| +--------------------+----------------------+----------------------+----------------------------+
1724+
| | :meth:`str.removeprefix` | :meth:`bytes.removeprefix` |
1725+
| +-------------------------------------------+---------------------------------------------------+
1726+
| | :meth:`str.removesuffix` | :meth:`bytes.removesuffix` |
1727+
+--------------------------+-------------------------------------------+---------------------------------------------------+
17241728
| Translation and Encoding | :meth:`str.translate` | :meth:`bytes.translate` |
17251729
| +-------------------------------------------+---------------------------------------------------+
17261730
| | :meth:`str.maketrans` | :meth:`bytes.maketrans` |

pr-preview/pr-1231/_sources/library/struct.rst.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The module defines the following exception and functions:
6868
Pack the values *v1*, *v2*, ... according to the format string *format* and
6969
write the packed bytes into the writable buffer *buffer* starting at
7070
position *offset*. Note that *offset* is a required argument.
71+
A negative *offset* counts from the end of *buffer*.
7172

7273

7374
.. function:: unpack(format, buffer)
@@ -84,6 +85,7 @@ The module defines the following exception and functions:
8485
string *format*. The result is a tuple even if it contains exactly one
8586
item. The buffer's size in bytes, starting at position *offset*, must be at
8687
least the size required by the format, as reflected by :func:`calcsize`.
88+
A negative *offset* counts from the end of *buffer*.
8789

8890

8991
.. function:: iter_unpack(format, buffer)

pr-preview/pr-1231/_sources/library/tkinter.dnd.rst.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ a single application, within the same window or between windows. To enable an
1616
object to be dragged, you must create an event binding for it that starts the
1717
drag-and-drop process. Typically, you bind a ButtonPress event to a callback
1818
function that you write (see :ref:`Bindings-and-Events`). The function should
19-
call :func:`dnd_start`, where 'source' is the object to be dragged, and 'event'
19+
call :func:`dnd_start`, where *source* is the object to be dragged, and *event*
2020
is the event that invoked the call (the argument to your callback function).
2121

2222
Selection of a target object occurs as follows:
2323

24-
#. Top-down search of area under mouse for target widget
24+
#. Top-down search of the area under the mouse for a target widget:
2525

26-
* Target widget should have a callable *dnd_accept* attribute
27-
* If *dnd_accept* is not present or returns ``None``, search moves to parent widget
28-
* If no target widget is found, then the target object is ``None``
26+
* the target widget should have a callable *dnd_accept* attribute;
27+
* if *dnd_accept* is not present or returns ``None``,
28+
the search moves to the parent widget;
29+
* if no target widget is found, the target object is ``None``.
2930

30-
2. Call to *<old_target>.dnd_leave(source, event)*
31-
#. Call to *<new_target>.dnd_enter(source, event)*
32-
#. Call to *<target>.dnd_commit(source, event)* to notify of drop
33-
#. Call to *<source>.dnd_end(target, event)* to signal end of drag-and-drop
31+
#. Call to ``<old_target>.dnd_leave(source, event)``.
32+
#. Call to ``<new_target>.dnd_enter(source, event)``.
33+
#. Call to ``<target>.dnd_commit(source, event)`` to notify of the drop.
34+
#. Call to ``<source>.dnd_end(target, event)`` to signal the end of drag-and-drop.
3435

3536

3637
.. class:: DndHandler(source, event)

0 commit comments

Comments
 (0)