Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fbd458

Browse files
committed
Merge branch 'python:main' into main
2 parents b6aee70 + 2513593 commit 7fbd458

138 files changed

Lines changed: 1779 additions & 928 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.

Android/android-env.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
: ${HOST:?} # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=21} # Minimum Android API level the build will run on
6+
: ${api_level:=24} # Minimum Android API level the build will run on
77
: ${PREFIX:-} # Path in which to find required libraries
88

99

@@ -24,7 +24,7 @@ fail() {
2424
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
2525
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
2626
# https://android.googlesource.com/platform/ndk/+/ndk-r25-release..ndk-r26-release/docs/BuildSystemMaintainers.md
27-
ndk_version=26.2.11394342
27+
ndk_version=27.1.12297006
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
3030
if ! [ -e $ndk ]; then
@@ -58,8 +58,8 @@ for path in "$AR" "$AS" "$CC" "$CXX" "$LD" "$NM" "$RANLIB" "$READELF" "$STRIP";
5858
fi
5959
done
6060

61-
export CFLAGS=""
62-
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment"
61+
export CFLAGS="-D__BIONIC_NO_PAGE_SIZE_MACRO"
62+
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384"
6363

6464
# Unlike Linux, Android does not implicitly use a dlopened library to resolve
6565
# relocations in subsequently-loaded libraries, even if RTLD_GLOBAL is used
@@ -85,6 +85,10 @@ if [ -n "${PREFIX:-}" ]; then
8585
export PKG_CONFIG_LIBDIR="$abs_prefix/lib/pkgconfig"
8686
fi
8787

88+
# When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
89+
# use CXXFLAGS alone.
90+
export CXXFLAGS=$CFLAGS
91+
8892
# Use the same variable name as conda-build
8993
if [ $(uname) = "Darwin" ]; then
9094
export CPU_COUNT=$(sysctl -n hw.ncpu)

Android/android.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def make_build_python(context):
138138

139139
def unpack_deps(host):
140140
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
141-
for name_ver in ["bzip2-1.0.8-1", "libffi-3.4.4-2", "openssl-3.0.15-0",
142-
"sqlite-3.45.1-0", "xz-5.4.6-0"]:
141+
for name_ver in ["bzip2-1.0.8-2", "libffi-3.4.4-3", "openssl-3.0.15-4",
142+
"sqlite-3.45.3-3", "xz-5.4.6-1"]:
143143
filename = f"{name_ver}-{host}.tar.gz"
144144
download(f"{deps_url}/{name_ver}/{filename}")
145145
run(["tar", "-xf", filename])
@@ -189,12 +189,13 @@ def configure_host_python(context):
189189

190190
def make_host_python(context):
191191
# The CFLAGS and LDFLAGS set in android-env include the prefix dir, so
192-
# delete any previously-installed Python libs and include files to prevent
193-
# them being used during the build.
192+
# delete any previous Python installation to prevent it being used during
193+
# the build.
194194
host_dir = subdir(context.host)
195195
prefix_dir = host_dir / "prefix"
196196
delete_glob(f"{prefix_dir}/include/python*")
197197
delete_glob(f"{prefix_dir}/lib/libpython*")
198+
delete_glob(f"{prefix_dir}/lib/python*")
198199

199200
os.chdir(host_dir / "build")
200201
run(["make", "-j", str(os.cpu_count())], host=context.host)

Android/testbed/app/build.gradle.kts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,47 @@ val PYTHON_VERSION = file("$PYTHON_DIR/Include/patchlevel.h").useLines {
3030
throw GradleException("Failed to find Python version")
3131
}
3232

33-
android.ndkVersion = file("../../android-env.sh").useLines {
34-
for (line in it) {
35-
val match = """ndk_version=(\S+)""".toRegex().find(line)
36-
if (match != null) {
37-
return@useLines match.groupValues[1]
38-
}
39-
}
40-
throw GradleException("Failed to find NDK version")
41-
}
42-
4333

4434
android {
35+
val androidEnvFile = file("../../android-env.sh").absoluteFile
36+
4537
namespace = "org.python.testbed"
4638
compileSdk = 34
4739

4840
defaultConfig {
4941
applicationId = "org.python.testbed"
50-
minSdk = 21
42+
43+
minSdk = androidEnvFile.useLines {
44+
for (line in it) {
45+
"""api_level:=(\d+)""".toRegex().find(line)?.let {
46+
return@useLines it.groupValues[1].toInt()
47+
}
48+
}
49+
throw GradleException("Failed to find API level in $androidEnvFile")
50+
}
5151
targetSdk = 34
52+
5253
versionCode = 1
5354
versionName = "1.0"
5455

5556
ndk.abiFilters.addAll(ABIS.keys)
5657
externalNativeBuild.cmake.arguments(
5758
"-DPYTHON_CROSS_DIR=$PYTHON_CROSS_DIR",
58-
"-DPYTHON_VERSION=$PYTHON_VERSION")
59+
"-DPYTHON_VERSION=$PYTHON_VERSION",
60+
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
61+
)
5962

6063
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
6164
}
6265

66+
ndkVersion = androidEnvFile.useLines {
67+
for (line in it) {
68+
"""ndk_version=(\S+)""".toRegex().find(line)?.let {
69+
return@useLines it.groupValues[1]
70+
}
71+
}
72+
throw GradleException("Failed to find NDK version in $androidEnvFile")
73+
}
6374
externalNativeBuild.cmake {
6475
path("src/main/c/CMakeLists.txt")
6576
}

Android/testbed/app/src/main/c/main_activity.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ typedef struct {
3434
int pipe[2];
3535
} StreamInfo;
3636

37+
// The FILE member can't be initialized here because stdout and stderr are not
38+
// compile-time constants. Instead, it's initialized immediately before the
39+
// redirection.
3740
static StreamInfo STREAMS[] = {
38-
{stdout, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
39-
{stderr, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
41+
{NULL, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
42+
{NULL, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
4043
{NULL, -1, ANDROID_LOG_UNKNOWN, NULL, {-1, -1}},
4144
};
4245

@@ -87,6 +90,8 @@ static char *redirect_stream(StreamInfo *si) {
8790
JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToLogcat(
8891
JNIEnv *env, jobject obj
8992
) {
93+
STREAMS[0].file = stdout;
94+
STREAMS[1].file = stderr;
9095
for (StreamInfo *si = STREAMS; si->file; si++) {
9196
char *error_prefix;
9297
if ((error_prefix = redirect_stream(si))) {

Android/testbed/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id("com.android.application") version "8.4.2" apply false
3+
id("com.android.application") version "8.6.1" apply false
44
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Mon Feb 19 20:29:06 GMT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

Doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494

9595
# Create table of contents entries for domain objects (e.g. functions, classes,
9696
# attributes, etc.). Default is True.
97-
toc_object_entries = False
97+
toc_object_entries = True
98+
toc_object_entries_show_parents = 'hide'
9899

99100
# Ignore any .rst files in the includes/ directory;
100101
# they're embedded in pages but not rendered individually.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ Pending removal in future versions
44
The following APIs will be removed in the future,
55
although there is currently no date scheduled for their removal.
66

7-
* :mod:`argparse`:
8-
9-
* Nesting argument groups and nesting mutually exclusive
10-
groups are deprecated.
11-
* Passing the undocumented keyword argument *prefix_chars* to
12-
:meth:`~argparse.ArgumentParser.add_argument_group` is now
13-
deprecated.
14-
15-
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
16-
177
* :mod:`builtins`:
188

199
* ``bool(NotImplemented)``.
@@ -43,6 +33,17 @@ although there is currently no date scheduled for their removal.
4333
as a single positional argument.
4434
(Contributed by Serhiy Storchaka in :gh:`109218`.)
4535

36+
* :mod:`argparse`:
37+
38+
* Nesting argument groups and nesting mutually exclusive
39+
groups are deprecated.
40+
* Passing the undocumented keyword argument *prefix_chars* to
41+
:meth:`~argparse.ArgumentParser.add_argument_group` is now
42+
deprecated.
43+
* The :class:`argparse.FileType` type converter is deprecated.
44+
45+
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
46+
4647
* :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are
4748
deprecated and replaced by :data:`calendar.JANUARY` and
4849
:data:`calendar.FEBRUARY`.

Doc/library/argparse.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,16 +865,14 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are:
865865
output files::
866866

867867
>>> parser = argparse.ArgumentParser()
868-
>>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
869-
... default=sys.stdin)
870-
>>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
871-
... default=sys.stdout)
868+
>>> parser.add_argument('infile', nargs='?')
869+
>>> parser.add_argument('outfile', nargs='?')
872870
>>> parser.parse_args(['input.txt', 'output.txt'])
873-
Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,
874-
outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)
871+
Namespace(infile='input.txt', outfile='output.txt')
872+
>>> parser.parse_args(['input.txt'])
873+
Namespace(infile='input.txt', outfile=None)
875874
>>> parser.parse_args([])
876-
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
877-
outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
875+
Namespace(infile=None, outfile=None)
878876

879877
.. index:: single: * (asterisk); in argparse module
880878

@@ -1033,7 +1031,6 @@ Common built-in types and functions can be used as type converters:
10331031
parser.add_argument('distance', type=float)
10341032
parser.add_argument('street', type=ascii)
10351033
parser.add_argument('code_point', type=ord)
1036-
parser.add_argument('dest_file', type=argparse.FileType('w', encoding='latin-1'))
10371034
parser.add_argument('datapath', type=pathlib.Path)
10381035

10391036
User defined functions can be used as well:
@@ -1827,9 +1824,19 @@ FileType objects
18271824
>>> parser.parse_args(['-'])
18281825
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)
18291826

1827+
.. note::
1828+
1829+
If one argument uses *FileType* and then a subsequent argument fails,
1830+
an error is reported but the file is not automatically closed.
1831+
This can also clobber the output files.
1832+
In this case, it would be better to wait until after the parser has
1833+
run and then use the :keyword:`with`-statement to manage the files.
1834+
18301835
.. versionchanged:: 3.4
18311836
Added the *encodings* and *errors* parameters.
18321837

1838+
.. deprecated:: 3.14
1839+
18331840

18341841
Argument groups
18351842
^^^^^^^^^^^^^^^

Doc/library/sys.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,35 @@ always available.
920920
It is not guaranteed to exist in all implementations of Python.
921921

922922

923+
.. function:: getobjects(limit[, type])
924+
925+
This function only exists if CPython was built using the
926+
specialized configure option :option:`--with-trace-refs`.
927+
It is intended only for debugging garbage-collection issues.
928+
929+
Return a list of up to *limit* dynamically allocated Python objects.
930+
If *type* is given, only objects of that exact type (not subtypes)
931+
are included.
932+
933+
Objects from the list are not safe to use.
934+
Specifically, the result will include objects from all interpreters that
935+
share their object allocator state (that is, ones created with
936+
:c:member:`PyInterpreterConfig.use_main_obmalloc` set to 1
937+
or using :c:func:`Py_NewInterpreter`, and the
938+
:ref:`main interpreter <sub-interpreter-support>`).
939+
Mixing objects from different interpreters may lead to crashes
940+
or other unexpected behavior.
941+
942+
.. impl-detail::
943+
944+
This function should be used for specialized purposes only.
945+
It is not guaranteed to exist in all implementations of Python.
946+
947+
.. versionchanged:: next
948+
949+
The result may include objects from other interpreters.
950+
951+
923952
.. function:: getprofile()
924953

925954
.. index::

0 commit comments

Comments
 (0)