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

Commit76eadef

Browse files
Deploy preview for PR 1160 🛫
1 parentf7cc646 commit76eadef

File tree

577 files changed

+1675
-889
lines changed

Some content is hidden

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

577 files changed

+1675
-889
lines changed

‎pr-preview/pr-1160/_sources/c-api/allocation.rst.txt‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ Allocating Objects on the Heap
140140
*:c:member:`~PyTypeObject.tp_alloc`
141141

142142

143-
..c:function::voidPyObject_Del(void *op)
144-
145-
Same as:c:func:`PyObject_Free`.
146-
147143
..c:var:: PyObject _Py_NoneStruct
148144
149145
Object which is visible in Python as ``None``. This should only be accessed
@@ -156,3 +152,35 @@ Allocating Objects on the Heap
156152
:ref:`moduleobjects`
157153
To allocate and create extension modules.
158154

155+
156+
Deprecated aliases
157+
^^^^^^^^^^^^^^^^^^
158+
159+
These are:term:`soft deprecated` aliases to existing functions and macros.
160+
They exist solely for backwards compatibility.
161+
162+
163+
..list-table::
164+
:widths: auto
165+
:header-rows: 1
166+
167+
* * Deprecated alias
168+
* Function
169+
* * .. c:macro:: PyObject_NEW(type, typeobj)
170+
*:c:macro:`PyObject_New`
171+
* * .. c:macro:: PyObject_NEW_VAR(type, typeobj, n)
172+
*:c:macro:`PyObject_NewVar`
173+
* * .. c:macro:: PyObject_INIT(op, typeobj)
174+
*:c:func:`PyObject_Init`
175+
* * .. c:macro:: PyObject_INIT_VAR(op, typeobj, n)
176+
*:c:func:`PyObject_InitVar`
177+
* * .. c:macro:: PyObject_MALLOC(n)
178+
*:c:func:`PyObject_Malloc`
179+
* * .. c:macro:: PyObject_REALLOC(p, n)
180+
*:c:func:`PyObject_Realloc`
181+
* * .. c:macro:: PyObject_FREE(p)
182+
*:c:func:`PyObject_Free`
183+
* * .. c:macro:: PyObject_DEL(p)
184+
*:c:func:`PyObject_Free`
185+
* * .. c:macro:: PyObject_Del(p)
186+
*:c:func:`PyObject_Free`

‎pr-preview/pr-1160/_sources/c-api/concrete.rst.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,13 @@ Other Objects
115115
gen.rst
116116
coro.rst
117117
contextvars.rst
118-
datetime.rst
119118
typehints.rst
119+
120+
121+
C API for extension modules
122+
===========================
123+
124+
..toctree::
125+
126+
curses.rst
127+
datetime.rst
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
..highlight::c
2+
3+
Curses C API
4+
------------
5+
6+
:mod:`curses` exposes a small C interface for extension modules.
7+
Consumers must include the header file:file:`py_curses.h` (which is not
8+
included by default by:file:`Python.h`) and:c:func:`import_curses` must
9+
be invoked, usually as part of the module initialisation function, to populate
10+
:c:var:`PyCurses_API`.
11+
12+
..warning::
13+
14+
Neither the C API nor the pure Python:mod:`curses` module are compatible
15+
with subinterpreters.
16+
17+
..c:macro:: import_curses()
18+
19+
Import the curses C API. The macro does not need a semi-colon to be called.
20+
21+
On success, populate the:c:var:`PyCurses_API` pointer.
22+
23+
On failure, set:c:var:`PyCurses_API` to NULL and set an exception.
24+
The caller must check if an error occurred via:c:func:`PyErr_Occurred`:
25+
26+
..code-block::
27+
28+
import_curses(); // semi-colon is optional but recommended
29+
if (PyErr_Occurred()) { /* cleanup */ }
30+
31+
32+
..c:var::void **PyCurses_API
33+
34+
Dynamically allocated object containing the curses C API.
35+
This variable is only available once:c:macro:`import_curses` succeeds.
36+
37+
``PyCurses_API[0]`` corresponds to:c:data:`PyCursesWindow_Type`.
38+
39+
``PyCurses_API[1]``, ``PyCurses_API[2]``, and ``PyCurses_API[3]``
40+
are pointers to predicate functions of type ``int (*)(void)``.
41+
42+
When called, these predicates return whether:func:`curses.setupterm`,
43+
:func:`curses.initscr`, and:func:`curses.start_color` have been called
44+
respectively.
45+
46+
See also the convenience macros:c:macro:`PyCursesSetupTermCalled`,
47+
:c:macro:`PyCursesInitialised`, and:c:macro:`PyCursesInitialisedColor`.
48+
49+
..note::
50+
51+
The number of entries in this structure is subject to changes.
52+
Consider using:c:macro:`PyCurses_API_pointers` to check if
53+
new fields are available or not.
54+
55+
56+
..c:macro:: PyCurses_API_pointers
57+
58+
The number of accessible fields (``4``) in:c:var:`PyCurses_API`.
59+
This number is incremented whenever new fields are added.
60+
61+
62+
..c:var:: PyTypeObject PyCursesWindow_Type
63+
64+
The:ref:`heap type<heap-types>` corresponding to:class:`curses.window`.
65+
66+
67+
..c:function::intPyCursesWindow_Check(PyObject *op)
68+
69+
Return true if *op* is a:class:`curses.window` instance, false otherwise.
70+
71+
72+
The following macros are convenience macros expanding into C statements.
73+
In particular, they can only be used as ``macro;`` or ``macro``, but not
74+
``macro()`` or ``macro();``.
75+
76+
..c:macro:: PyCursesSetupTermCalled
77+
78+
Macro checking if:func:`curses.setupterm` has been called.
79+
80+
The macro expansion is roughly equivalent to:
81+
82+
..code-block::
83+
84+
{
85+
typedef int (*predicate_t)(void);
86+
predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];
87+
if (!was_setupterm_called()) {
88+
return NULL;
89+
}
90+
}
91+
92+
93+
..c:macro:: PyCursesInitialised
94+
95+
Macro checking if:func:`curses.initscr` has been called.
96+
97+
The macro expansion is roughly equivalent to:
98+
99+
..code-block::
100+
101+
{
102+
typedef int (*predicate_t)(void);
103+
predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];
104+
if (!was_initscr_called()) {
105+
return NULL;
106+
}
107+
}
108+
109+
110+
..c:macro:: PyCursesInitialisedColor
111+
112+
Macro checking if:func:`curses.start_color` has been called.
113+
114+
The macro expansion is roughly equivalent to:
115+
116+
..code-block::
117+
118+
{
119+
typedef int (*predicate_t)(void);
120+
predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];
121+
if (!was_start_color_called()) {
122+
return NULL;
123+
}
124+
}
125+
126+
127+
Internal data
128+
-------------
129+
130+
The following objects are exposed by the C API but should be considered
131+
internal-only.
132+
133+
..c:macro:: PyCurses_CAPSULE_NAME
134+
135+
Name of the curses capsule to pass to:c:func:`PyCapsule_Import`.
136+
137+
Internal usage only. Use:c:macro:`import_curses` instead.
138+

‎pr-preview/pr-1160/_sources/c-api/veryhigh.rst.txt‎

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ the interpreter.
1313

1414
Several of these functions accept a start symbol from the grammar as a
1515
parameter. The available start symbols are:c:data:`Py_eval_input`,
16-
:c:data:`Py_file_input`, and:c:data:`Py_single_input`. These are described
17-
following the functions which accept them as parameters.
16+
:c:data:`Py_file_input`,:c:data:`Py_single_input`, and
17+
:c:data:`Py_func_type_input`. These are described following the functions
18+
which accept them as parameters.
1819

1920
Note also that several of these functions take:c:expr:`FILE*` parameters. One
2021
particular issue which needs to be handled carefully is that the:c:type:`FILE`
@@ -183,8 +184,7 @@ the same library that the Python runtime is using.
183184
objects *globals* and *locals* with the compiler flags specified by
184185
*flags*. *globals* must be a dictionary; *locals* can be any object
185186
that implements the mapping protocol. The parameter *start* specifies
186-
the start symbol and must one of the following:
187-
:c:data:`Py_eval_input`,:c:data:`Py_file_input`, or:c:data:`Py_single_input`.
187+
the start symbol and must one of the:ref:`available start symbols<start-symbols>`.
188188
189189
Returns the result of executing the code as a Python object, or ``NULL`` if an
190190
exception was raised.
@@ -233,8 +233,8 @@ the same library that the Python runtime is using.
233233
234234
Parse and compile the Python source code in *str*, returning the resulting code
235235
object. The start symbol is given by *start*; this can be used to constrain the
236-
code which can be compiled and should be:c:data:`Py_eval_input`,
237-
:c:data:`Py_file_input`, or:c:data:`Py_single_input`. The filename specified by
236+
code which can be compiled and should be:ref:`available start symbols
237+
<start-symbols>`. The filename specified by
238238
*filename* is used to construct the code object and may appear in tracebacks or
239239
:exc:`SyntaxError` exception messages. This returns ``NULL`` if the code
240240
cannot be parsed or compiled.
@@ -297,32 +297,6 @@ the same library that the Python runtime is using.
297297
true on success, false on failure.
298298
299299
300-
..c:var::int Py_eval_input
301-
302-
..index::single: Py_CompileString (C function)
303-
304-
The start symbol from the Python grammar for isolated expressions; for use with
305-
:c:func:`Py_CompileString`.
306-
307-
308-
..c:var::int Py_file_input
309-
310-
..index::single: Py_CompileString (C function)
311-
312-
The start symbol from the Python grammar for sequences of statements as read
313-
from a file or other source; for use with:c:func:`Py_CompileString`. This is
314-
the symbol to use when compiling arbitrarily long Python source code.
315-
316-
317-
..c:var::int Py_single_input
318-
319-
..index::single: Py_CompileString (C function)
320-
321-
The start symbol from the Python grammar for a single statement; for use with
322-
:c:func:`Py_CompileString`. This is the symbol used for the interactive
323-
interpreter loop.
324-
325-
326300
..c:struct:: PyCompilerFlags
327301
328302
This is the structure used to hold compiler flags. In cases where code is only
@@ -366,3 +340,52 @@ the same library that the Python runtime is using.
366340
as:c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally
367341
selectable using:ref:`future statements<future>`.
368342
See:ref:`c_codeobject_flags` for a complete list.
343+
344+
345+
.. _start-symbols:
346+
347+
Available start symbols
348+
^^^^^^^^^^^^^^^^^^^^^^^
349+
350+
351+
..c:var::int Py_eval_input
352+
353+
..index::single: Py_CompileString (C function)
354+
355+
The start symbol from the Python grammar for isolated expressions; for use with
356+
:c:func:`Py_CompileString`.
357+
358+
359+
..c:var::int Py_file_input
360+
361+
..index::single: Py_CompileString (C function)
362+
363+
The start symbol from the Python grammar for sequences of statements as read
364+
from a file or other source; for use with:c:func:`Py_CompileString`. This is
365+
the symbol to use when compiling arbitrarily long Python source code.
366+
367+
368+
..c:var::int Py_single_input
369+
370+
..index::single: Py_CompileString (C function)
371+
372+
The start symbol from the Python grammar for a single statement; for use with
373+
:c:func:`Py_CompileString`. This is the symbol used for the interactive
374+
interpreter loop.
375+
376+
377+
..c:var::int Py_func_type_input
378+
379+
..index::single: Py_CompileString (C function)
380+
381+
The start symbol from the Python grammar for a function type; for use with
382+
:c:func:`Py_CompileString`. This is used to parse "signature type comments"
383+
from:pep:`484`.
384+
385+
This requires the:c:macro:`PyCF_ONLY_AST` flag to be set.
386+
387+
..seealso::
388+
*:py:class:`ast.FunctionType`
389+
*:pep:`484`
390+
391+
..versionadded::3.8

‎pr-preview/pr-1160/_sources/c-api/weakref.rst.txt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ as much as it can.
1919
2020
..c:function::intPyWeakref_CheckRef(PyObject *ob)
2121
22-
Return non-zero if *ob* is a reference object. This function always succeeds.
22+
Return non-zero if *ob* is a reference object or a subclass of the reference
23+
type. This function always succeeds.
24+
25+
26+
..c:function::intPyWeakref_CheckRefExact(PyObject *ob)
27+
28+
Return non-zero if *ob* is a reference object, but not a subclass of the
29+
reference type. This function always succeeds.
2330
2431
2532
..c:function::intPyWeakref_CheckProxy(PyObject *ob)

‎pr-preview/pr-1160/_sources/library/os.rst.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,6 +3505,9 @@ features:
35053505

35063506
Create a symbolic link pointing to *src* named *dst*.
35073507

3508+
The *src* parameter refers to the target of the link (the file or directory being linked to),
3509+
and *dst* is the name of the link being created.
3510+
35083511
On Windows, a symlink represents either a file or a directory, and does not
35093512
morph to the target dynamically. If the target is present, the type of the
35103513
symlink will be created to match. Otherwise, the symlink will be created

‎pr-preview/pr-1160/about.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ <h3>導航</h3>
314314
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
315315
<br>
316316
<br>
317-
最後更新於 11月 09, 2025 (00:23 UTC)。
317+
最後更新於 11月 09, 2025 (17:08 UTC)。
318318

319319
<ahref="/bugs.html">發現 bug</a>
320320

‎pr-preview/pr-1160/bugs.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ <h3>導航</h3>
351351
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
352352
<br>
353353
<br>
354-
最後更新於 11月 09, 2025 (00:23 UTC)。
354+
最後更新於 11月 09, 2025 (17:08 UTC)。
355355

356356
<ahref="/bugs.html">發現 bug</a>
357357

‎pr-preview/pr-1160/c-api/abstract.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ <h3>導航</h3>
323323
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
324324
<br>
325325
<br>
326-
最後更新於 11月 09, 2025 (00:23 UTC)。
326+
最後更新於 11月 09, 2025 (17:08 UTC)。
327327

328328
<ahref="/bugs.html">發現 bug</a>
329329

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp