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

Commit42c57d7

Browse files
authored
Merge branch 'main' into 131769-wasi-bebug-main
2 parents058ae0e +ad42dc1 commit42c57d7

File tree

189 files changed

+2521
-1769
lines changed

Some content is hidden

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

189 files changed

+2521
-1769
lines changed

‎.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ permissions:
1515
contents:read
1616

1717
concurrency:
18-
group:${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
18+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
19+
# 'group' must be a key uniquely representing a PR or push event.
20+
# github.workflow is the workflow name
21+
# github.actor is the user invoking the workflow
22+
# github.head_ref is the source branch of the PR or otherwise blank
23+
# github.run_id is a unique number for the current run
24+
group:${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
1925
cancel-in-progress:true
2026

2127
env:

‎Doc/howto/annotations.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,9 @@ quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or
248248
:func:`inspect.get_annotations` on Python 3.10+. On earlier versions of
249249
Python, you can avoid these bugs by accessing the annotations from the
250250
class's:attr:`~type.__dict__`
251-
(e.g., ``cls.__dict__.get('__annotations__', None)``).
251+
(for example, ``cls.__dict__.get('__annotations__', None)``).
252+
253+
In some versions of Python, instances of classes may have an ``__annotations__``
254+
attribute. However, this is not supported functionality. If you need the
255+
annotations of an instance, you can use:func:`type` to access its class
256+
(for example, ``annotationlib.get_annotations(type(myinstance))`` on Python 3.14+).

‎Doc/howto/isolating-extensions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,36 @@ multiple interpreters correctly. If this is not yet the case for your
215215
module, you can explicitly make your module loadable only once per
216216
process. For example::
217217

218+
// A process-wide flag
218219
static int loaded = 0;
219220

221+
// Mutex to provide thread safety (only needed for free-threaded Python)
222+
static PyMutex modinit_mutex = {0};
223+
220224
static int
221225
exec_module(PyObject* module)
222226
{
227+
PyMutex_Lock(&modinit_mutex);
223228
if (loaded) {
229+
PyMutex_Unlock(&modinit_mutex);
224230
PyErr_SetString(PyExc_ImportError,
225231
"cannot load module more than once per process");
226232
return -1;
227233
}
228234
loaded = 1;
235+
PyMutex_Unlock(&modinit_mutex);
229236
// ... rest of initialization
230237
}
231238

232239

240+
If your module's:c:member:`PyModuleDef.m_clear` function is able to prepare
241+
for future re-initialization, it should clear the ``loaded`` flag.
242+
In this case, your module won't support multiple instances existing
243+
*concurrently*, but it will, for example, support being loaded after
244+
Python runtime shutdown (:c:func:`Py_FinalizeEx`) and re-initialization
245+
(:c:func:`Py_Initialize`).
246+
247+
233248
Module State Access from Functions
234249
----------------------------------
235250

‎Doc/tools/templates/customsourcelink.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{%- if show_source and has_source and sourcename %}
22
<divrole="note"aria-label="source link">
3-
<h3>{{ _('ThisPage') }}</h3>
3+
<h3>{{ _('Thispage') }}</h3>
44
<ulclass="this-page-menu">
5-
<li><ahref="{{ pathto('bugs') }}">{% trans %}Report aBug{% endtrans %}</a></li>
5+
<li><ahref="{{ pathto('bugs') }}">{% trans %}Report abug{% endtrans %}</a></li>
66
<li>
77
<ahref="https://github.com/python/cpython/blob/main/Doc/{{ sourcename|replace('.rst.txt', '.rst') }}"
8-
rel="nofollow">{{ _('ShowSource') }}
8+
rel="nofollow">{{ _('Showsource') }}
99
</a>
1010
</li>
1111
</ul>

‎Doc/tools/templates/download.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{%- endblock -%}
2828

2929
{% block body %}
30-
<h1>{% trans %}Download Python {{ dl_version }}Documentation{% endtrans %}</h1>
30+
<h1>{% trans %}Download Python {{ dl_version }}documentation{% endtrans %}</h1>
3131

3232
{% if last_updated %}<p><b>{% trans %}Last updated on: {{ last_updated }}.{% endtrans %}</b></p>{% endif %}
3333

‎Doc/tools/templates/indexcontent.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h1>{{ docstitle|e }}</h1>
7272
<tableclass="contentstable"align="center"><tr>
7373
<tdwidth="50%">
7474
<pclass="biglink"><aclass="biglink"href="{{ pathto("bugs") }}">{% trans %}Reporting issues{% endtrans %}</a></p>
75-
<pclass="biglink"><aclass="biglink"href="https://devguide.python.org/documentation/help-documenting/">{% trans %}Contributing toDocs{% endtrans %}</a></p>
75+
<pclass="biglink"><aclass="biglink"href="https://devguide.python.org/documentation/help-documenting/">{% trans %}Contributing todocs{% endtrans %}</a></p>
7676
<pclass="biglink"><aclass="biglink"href="{{ pathto("download") }}">{% trans %}Download the documentation{% endtrans %}</a></p>
7777
</td><tdwidth="50%">
7878
<pclass="biglink"><aclass="biglink"href="{{ pathto("license") }}">{% trans %}History and license of Python{% endtrans %}</a></p>

‎Doc/tools/templates/indexsidebar.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ <h3>{% trans %}Docs by version{% endtrans %}</h3>
99
<h3>{% trans %}Other resources{% endtrans %}</h3>
1010
<ul>
1111
{# XXX: many of these should probably be merged in the main docs #}
12-
<li><ahref="https://peps.python.org/">{% trans %}PEPIndex{% endtrans %}</a></li>
13-
<li><ahref="https://wiki.python.org/moin/BeginnersGuide">{% trans %}Beginner'sGuide{% endtrans %}</a></li>
14-
<li><ahref="https://wiki.python.org/moin/PythonBooks">{% trans %}BookList{% endtrans %}</a></li>
15-
<li><ahref="https://www.python.org/doc/av/">{% trans %}Audio/Visual Talks{% endtrans %}</a></li>
16-
<li><ahref="https://devguide.python.org/">{% trans %}PythonDeveloper’sGuide{% endtrans %}</a></li>
12+
<li><ahref="https://peps.python.org/">{% trans %}PEPindex{% endtrans %}</a></li>
13+
<li><ahref="https://wiki.python.org/moin/BeginnersGuide">{% trans %}Beginner'sguide{% endtrans %}</a></li>
14+
<li><ahref="https://wiki.python.org/moin/PythonBooks">{% trans %}Booklist{% endtrans %}</a></li>
15+
<li><ahref="https://www.python.org/doc/av/">{% trans %}Audio/visual talks{% endtrans %}</a></li>
16+
<li><ahref="https://devguide.python.org/">{% trans %}Pythondeveloper’sguide{% endtrans %}</a></li>
1717
</ul>

‎Doc/tutorial/index.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
The Python Tutorial
55
######################
66

7+
..Tip::This tutorial is designed for
8+
*programmers* that are new to the Python language,
9+
**not** *beginners* who are new to programming.
10+
711
Python is an easy to learn, powerful programming language. It has efficient
812
high-level data structures and a simple but effective approach to
913
object-oriented programming. Python's elegant syntax and dynamic typing,
@@ -21,7 +25,8 @@ implemented in C or C++ (or other languages callable from C). Python is also
2125
suitable as an extension language for customizable applications.
2226

2327
This tutorial introduces the reader informally to the basic concepts and
24-
features of the Python language and system. It helps to have a Python
28+
features of the Python language and system. Be aware that it expects you to
29+
have a basic understanding of programming in general. It helps to have a Python
2530
interpreter handy for hands-on experience, but all examples are self-contained,
2631
so the tutorial can be read off-line as well.
2732

‎Include/internal/pycore_backoff.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ backoff_counter_triggers(_Py_BackoffCounter counter)
9595
returncounter.value_and_backoff<UNREACHABLE_BACKOFF;
9696
}
9797

98-
/* Initial JUMP_BACKWARD counter.
99-
* This determines when we create a trace for a loop. */
98+
// Initial JUMP_BACKWARD counter.
99+
// Must be larger than ADAPTIVE_COOLDOWN_VALUE, otherwise when JIT code is
100+
// invalidated we may construct a new trace before the bytecode has properly
101+
// re-specialized:
100102
#defineJUMP_BACKWARD_INITIAL_VALUE 4095
101103
#defineJUMP_BACKWARD_INITIAL_BACKOFF 12
102104
staticinline_Py_BackoffCounter

‎Include/internal/pycore_code.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
451451
#defineADAPTIVE_COOLDOWN_BACKOFF 0
452452

453453
// Can't assert this in pycore_backoff.h because of header order dependencies
454+
#ifJUMP_BACKWARD_INITIAL_VALUE <=ADAPTIVE_COOLDOWN_VALUE
455+
# error "JIT threshold value should be larger than adaptive cooldown value"
456+
#endif
454457
#ifSIDE_EXIT_INITIAL_VALUE <=ADAPTIVE_COOLDOWN_VALUE
455458
# error "Cold exit value should be larger than adaptive cooldown value"
456459
#endif

‎Include/internal/pycore_crossinterp.h

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -335,71 +335,29 @@ typedef struct _sharedexception {
335335
PyAPI_FUNC(PyObject*)_PyXI_ApplyError(_PyXI_error*err);
336336

337337

338-
typedefstructxi_session_PyXI_session;
339-
typedefstruct_sharedns_PyXI_namespace;
340-
341-
PyAPI_FUNC(void)_PyXI_FreeNamespace(_PyXI_namespace*ns);
342-
PyAPI_FUNC(_PyXI_namespace*)_PyXI_NamespaceFromNames(PyObject*names);
343-
PyAPI_FUNC(int)_PyXI_FillNamespaceFromDict(
344-
_PyXI_namespace*ns,
345-
PyObject*nsobj,
346-
_PyXI_session*session);
347-
PyAPI_FUNC(int)_PyXI_ApplyNamespace(
348-
_PyXI_namespace*ns,
349-
PyObject*nsobj,
350-
PyObject*dflt);
351-
352-
353338
// A cross-interpreter session involves entering an interpreter
354-
//(_PyXI_Enter()), doing some work with it, and finally exiting
355-
// that interpreter(_PyXI_Exit()).
339+
//with_PyXI_Enter(), doing some work with it, and finally exiting
340+
// that interpreterwith_PyXI_Exit().
356341
//
357342
// At the boundaries of the session, both entering and exiting,
358343
// data may be exchanged between the previous interpreter and the
359344
// target one in a thread-safe way that does not violate the
360345
// isolation between interpreters. This includes setting objects
361346
// in the target's __main__ module on the way in, and capturing
362347
// uncaught exceptions on the way out.
363-
structxi_session {
364-
// Once a session has been entered, this is the tstate that was
365-
// current before the session. If it is different from cur_tstate
366-
// then we must have switched interpreters. Either way, this will
367-
// be the current tstate once we exit the session.
368-
PyThreadState*prev_tstate;
369-
// Once a session has been entered, this is the current tstate.
370-
// It must be current when the session exits.
371-
PyThreadState*init_tstate;
372-
// This is true if init_tstate needs cleanup during exit.
373-
intown_init_tstate;
374-
375-
// This is true if, while entering the session, init_thread took
376-
// "ownership" of the interpreter's __main__ module. This means
377-
// it is the only thread that is allowed to run code there.
378-
// (Caveat: for now, users may still run exec() against the
379-
// __main__ module's dict, though that isn't advisable.)
380-
intrunning;
381-
// This is a cached reference to the __dict__ of the entered
382-
// interpreter's __main__ module. It is looked up when at the
383-
// beginning of the session as a convenience.
384-
PyObject*main_ns;
385-
386-
// This is set if the interpreter is entered and raised an exception
387-
// that needs to be handled in some special way during exit.
388-
_PyXI_errcode*error_override;
389-
// This is set if exit captured an exception to propagate.
390-
_PyXI_error*error;
391-
392-
// -- pre-allocated memory --
393-
_PyXI_error_error;
394-
_PyXI_errcode_error_override;
395-
};
348+
typedefstructxi_session_PyXI_session;
349+
350+
PyAPI_FUNC(_PyXI_session*)_PyXI_NewSession(void);
351+
PyAPI_FUNC(void)_PyXI_FreeSession(_PyXI_session*);
396352

397353
PyAPI_FUNC(int)_PyXI_Enter(
398354
_PyXI_session*session,
399355
PyInterpreterState*interp,
400356
PyObject*nsupdates);
401357
PyAPI_FUNC(void)_PyXI_Exit(_PyXI_session*session);
402358

359+
PyAPI_FUNC(PyObject*)_PyXI_GetMainNamespace(_PyXI_session*);
360+
403361
PyAPI_FUNC(PyObject*)_PyXI_ApplyCapturedException(_PyXI_session*session);
404362
PyAPI_FUNC(int)_PyXI_HasCapturedException(_PyXI_session*session);
405363

‎Include/internal/pycore_opcode_metadata.h

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/internal/pycore_pyerrors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ extern void _PyErr_Fetch(
9494
PyObject**value,
9595
PyObject**traceback);
9696

97-
externPyObject*_PyErr_GetRaisedException(PyThreadState*tstate);
97+
PyAPI_FUNC(PyObject*)_PyErr_GetRaisedException(PyThreadState*tstate);
9898

9999
PyAPI_FUNC(int)_PyErr_ExceptionMatches(
100100
PyThreadState*tstate,
101101
PyObject*exc);
102102

103-
externvoid_PyErr_SetRaisedException(PyThreadState*tstate,PyObject*exc);
103+
PyAPI_FUNC(void)_PyErr_SetRaisedException(PyThreadState*tstate,PyObject*exc);
104104

105105
externvoid_PyErr_Restore(
106106
PyThreadState*tstate,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp