Skip to content

Commit 25316b8

Browse files
authored
Merge branch 'main' into patch-1
2 parents 49699d6 + c6d4c79 commit 25316b8

Some content is hidden

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

50 files changed

+546
-160
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,29 @@ jobs:
414414
- name: Build and test
415415
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android
416416

417+
build-ios:
418+
name: iOS
419+
needs: build-context
420+
if: needs.build-context.outputs.run-tests == 'true'
421+
timeout-minutes: 60
422+
runs-on: macos-15
423+
steps:
424+
- uses: actions/checkout@v4
425+
with:
426+
persist-credentials: false
427+
428+
# GitHub recommends explicitly selecting the desired Xcode version:
429+
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
430+
# This became a necessity as a result of
431+
# https://github.com/actions/runner-images/issues/12541 and
432+
# https://github.com/actions/runner-images/issues/12751.
433+
- name: Select Xcode version
434+
run: |
435+
sudo xcode-select --switch /Applications/Xcode_16.4.app
436+
437+
- name: Build and test
438+
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone 16e,OS=18.5'
439+
417440
build-wasi:
418441
name: 'WASI'
419442
needs: build-context
@@ -723,6 +746,7 @@ jobs:
723746
- build-ubuntu-ssltests-awslc
724747
- build-ubuntu-ssltests-openssl
725748
- build-android
749+
- build-ios
726750
- build-wasi
727751
- test-hypothesis
728752
- build-asan
@@ -759,6 +783,7 @@ jobs:
759783
build-ubuntu-ssltests-awslc,
760784
build-ubuntu-ssltests-openssl,
761785
build-android,
786+
build-ios,
762787
build-wasi,
763788
test-hypothesis,
764789
build-asan,

Apple/__main__.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
823823
+ [
824824
"--",
825825
"test",
826-
"--slow-ci" if context.slow else "--fast-ci",
826+
f"--{context.ci_mode}-ci",
827827
"--single-process",
828828
"--no-randomize",
829829
# Timeout handling requires subprocesses; explicitly setting
@@ -836,11 +836,39 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
836836
)
837837

838838

839+
def apple_sim_host(platform_name: str) -> str:
840+
"""Determine the native simulator target for this platform."""
841+
for _, slice_parts in HOSTS[platform_name].items():
842+
for host_triple in slice_parts:
843+
parts = host_triple.split('-')
844+
if parts[0] == platform.machine() and parts[-1] == "simulator":
845+
return host_triple
846+
847+
raise KeyError(platform_name)
848+
849+
839850
def ci(context: argparse.Namespace) -> None:
840-
"""The implementation of the "ci" command."""
851+
"""The implementation of the "ci" command.
852+
853+
In "Fast" mode, this compiles the build python, and the simulator for the
854+
build machine's architecture; and runs the test suite with `--fast-ci`
855+
configuration.
856+
857+
In "Slow" mode, it compiles the build python, plus all candidate
858+
architectures (both device and simulator); then runs the test suite with
859+
`--slow-ci` configuration.
860+
"""
841861
clean(context, "all")
842-
build(context, host="all")
843-
test(context, host="all")
862+
if context.ci_mode == "slow":
863+
# In slow mode, build and test the full XCframework
864+
build(context, host="all")
865+
test(context, host="all")
866+
else:
867+
# In fast mode, just build the simulator platform.
868+
sim_host = apple_sim_host(context.platform)
869+
build(context, host="build")
870+
build(context, host=sim_host)
871+
test(context, host=sim_host)
844872

845873

846874
def parse_args() -> argparse.Namespace:
@@ -947,11 +975,13 @@ def parse_args() -> argparse.Namespace:
947975
"an ARM64 iPhone 16 Pro simulator running iOS 26.0."
948976
),
949977
)
950-
cmd.add_argument(
951-
"--slow",
952-
action="store_true",
953-
help="Run tests with --slow-ci options.",
954-
)
978+
group = cmd.add_mutually_exclusive_group()
979+
group.add_argument(
980+
"--fast-ci", action="store_const", dest="ci_mode", const="fast",
981+
help="Add test arguments for GitHub Actions")
982+
group.add_argument(
983+
"--slow-ci", action="store_const", dest="ci_mode", const="slow",
984+
help="Add test arguments for buildbots")
955985

956986
for subcommand in [configure_build, configure_host, build, ci]:
957987
subcommand.add_argument(
@@ -1012,4 +1042,10 @@ def signal_handler(*args):
10121042

10131043

10141044
if __name__ == "__main__":
1045+
# Under the buildbot, stdout is not a TTY, but we must still flush after
1046+
# every line to make sure our output appears in the correct order relative
1047+
# to the output of our subprocesses.
1048+
for stream in [sys.stdout, sys.stderr]:
1049+
stream.reconfigure(line_buffering=True)
1050+
10151051
main()

Apple/testbed/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,9 @@ def main():
412412

413413

414414
if __name__ == "__main__":
415+
# Under the buildbot, stdout is not a TTY, but we must still flush after
416+
# every line to make sure our output appears in the correct order relative
417+
# to the output of our subprocesses.
418+
for stream in [sys.stdout, sys.stderr]:
419+
stream.reconfigure(line_buffering=True)
415420
main()

Doc/c-api/codec.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Codec registry and support functions
3939
*object* is passed through the decoder function found for the given
4040
*encoding* using the error handling method defined by *errors*. *errors* may
4141
be ``NULL`` to use the default method defined for the codec. Raises a
42-
:exc:`LookupError` if no encoder can be found.
42+
:exc:`LookupError` if no decoder can be found.
4343
4444
4545
Codec lookup API

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ use a thread key and functions to associate a :c:expr:`void*` value per
21402140
thread.
21412141
21422142
A :term:`thread state` does *not* need to be :term:`attached <attached thread state>`
2143-
when calling these functions; they suppl their own locking.
2143+
when calling these functions; they supply their own locking.
21442144
21452145
Note that :file:`Python.h` does not include the declaration of the TLS APIs,
21462146
you need to include :file:`pythread.h` to use thread-local storage.

Grammar/python.gram

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,11 +1416,11 @@ invalid_import:
14161416
| 'import' token=NEWLINE {
14171417
RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
14181418
invalid_dotted_as_name:
1419-
| dotted_name 'as' !(NAME (',' | ')' | NEWLINE)) a=expression {
1419+
| dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) a=expression {
14201420
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
14211421
"cannot use %s as import target", _PyPegen_get_expr_name(a)) }
14221422
invalid_import_from_as_name:
1423-
| NAME 'as' !(NAME (',' | ')' | NEWLINE)) a=expression {
1423+
| NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) a=expression {
14241424
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
14251425
"cannot use %s as import target", _PyPegen_get_expr_name(a)) }
14261426

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ struct _is {
939939
struct _PyExecutorObject *executor_deletion_list_head;
940940
struct _PyExecutorObject *cold_executor;
941941
int executor_deletion_list_remaining_capacity;
942-
size_t trace_run_counter;
942+
size_t executor_creation_counter;
943943
_rare_events rare_events;
944944
PyDict_WatchCallback builtins_dict_watcher;
945945

Include/internal/pycore_optimizer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyInterpreterState *interp);
9090
#endif
9191

9292
// Used as the threshold to trigger executor invalidation when
93-
// trace_run_counter is greater than this value.
94-
#define JIT_CLEANUP_THRESHOLD 100000
93+
// executor_creation_counter is greater than this value.
94+
// This value is arbitrary and was not optimized.
95+
#define JIT_CLEANUP_THRESHOLD 1000
9596

9697
#define TRACE_STACK_SIZE 5
9798

Include/internal/pycore_pystate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _Py_ThreadCanHandleSignals(PyInterpreterState *interp)
8989
/* Variable and static inline functions for in-line access to current thread
9090
and interpreter state */
9191

92-
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
92+
#if !defined(Py_BUILD_CORE_MODULE)
9393
extern _Py_thread_local PyThreadState *_Py_tss_tstate;
9494
extern _Py_thread_local PyInterpreterState *_Py_tss_interp;
9595
#endif
@@ -115,7 +115,7 @@ PyAPI_FUNC(PyThreadState *) _PyThreadState_GetCurrent(void);
115115
static inline PyThreadState*
116116
_PyThreadState_GET(void)
117117
{
118-
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
118+
#if !defined(Py_BUILD_CORE_MODULE)
119119
return _Py_tss_tstate;
120120
#else
121121
return _PyThreadState_GetCurrent();

Include/internal/pycore_traceback.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ extern int _Py_WriteIndent(int, PyObject *);
103103
PyAPI_FUNC(void) _Py_InitDumpStack(void);
104104
PyAPI_FUNC(void) _Py_DumpStack(int fd);
105105

106+
extern void _Py_DumpTraceback_Init(void);
107+
106108
#ifdef __cplusplus
107109
}
108110
#endif

0 commit comments

Comments
 (0)