Skip to content

Commit 11b23ac

Browse files
committed
feat: update code from upstream 3.14.3
1 parent b729048 commit 11b23ac

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project
66
adheres to [Semantic Versioning](https://semver.org/).
77

8+
## Unreleased
9+
10+
### :rocket: Added
11+
12+
- Update code with CPython 3.14.3 version
13+
814
## [1.3.0] - 2025-12-29
915

1016
[1.3.0]: https://github.com/rogdham/backports.zstd/releases/tag/v1.3.0

tests/test/support/__init__.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"record_original_stdout", "get_original_stdout", "captured_stdout",
3131
"captured_stdin", "captured_stderr", "captured_output",
3232
# unittest
33-
"is_resource_enabled", "requires", "requires_freebsd_version",
33+
"is_resource_enabled", "get_resource_value", "requires", "requires_resource",
34+
"requires_freebsd_version",
3435
"requires_gil_enabled", "requires_linux_version", "requires_mac_ver",
3536
"check_syntax_error",
3637
"requires_gzip", "requires_bz2", "requires_lzma", "requires_zstd",
@@ -43,6 +44,7 @@
4344
"check__all__", "skip_if_buggy_ucrt_strfptime",
4445
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
4546
"requires_limited_api", "requires_specialization", "thread_unsafe",
47+
"skip_if_unlimited_stack_size",
4648
# sys
4749
"MS_WINDOWS", "is_jython", "is_android", "is_emscripten", "is_wasi",
4850
"is_apple_mobile", "check_impl_detail", "unix_shell", "setswitchinterval",
@@ -184,7 +186,7 @@ def get_attribute(obj, name):
184186
return attribute
185187

186188
verbose = 1 # Flag set to 0 by regrtest.py
187-
use_resources = None # Flag set to [] by regrtest.py
189+
use_resources = None # Flag set to {} by regrtest.py
188190
max_memuse = 0 # Disable bigmem tests (they will still be run with
189191
# small sizes, to make sure they work.)
190192
real_max_memuse = 0
@@ -299,6 +301,16 @@ def is_resource_enabled(resource):
299301
"""
300302
return use_resources is None or resource in use_resources
301303

304+
def get_resource_value(resource):
305+
"""Test whether a resource is enabled.
306+
307+
Known resources are set by regrtest.py. If not running under regrtest.py,
308+
all resources are assumed enabled unless use_resources has been set.
309+
"""
310+
if use_resources is None:
311+
return None
312+
return use_resources.get(resource)
313+
302314
def requires(resource, msg=None):
303315
"""Raise ResourceDenied if the specified resource is not available."""
304316
if not is_resource_enabled(resource):
@@ -1669,6 +1681,25 @@ def skip_if_pgo_task(test):
16691681
return test if ok else unittest.skip(msg)(test)
16701682

16711683

1684+
def skip_if_unlimited_stack_size(test):
1685+
"""Skip decorator for tests not run when an unlimited stack size is configured.
1686+
1687+
Tests using support.infinite_recursion([...]) may otherwise run into
1688+
an infinite loop, running until the memory on the system is filled and
1689+
crashing due to OOM.
1690+
1691+
See https://github.com/python/cpython/issues/143460.
1692+
"""
1693+
if is_emscripten or is_wasi or os.name == "nt":
1694+
return test
1695+
1696+
import resource
1697+
curlim, maxlim = resource.getrlimit(resource.RLIMIT_STACK)
1698+
unlimited_stack_size_cond = curlim == maxlim and curlim in (-1, 0xFFFF_FFFF_FFFF_FFFF)
1699+
reason = "Not run due to unlimited stack size"
1700+
return unittest.skipIf(unlimited_stack_size_cond, reason)(test)
1701+
1702+
16721703
def detect_api_mismatch(ref_api, other_api, *, ignore=()):
16731704
"""Returns the set of items in ref_api not in other_api, except for a
16741705
defined list of items to be ignored in this check.
@@ -3184,3 +3215,10 @@ def linked_to_musl():
31843215
return _linked_to_musl
31853216
_linked_to_musl = tuple(map(int, version.split('.')))
31863217
return _linked_to_musl
3218+
3219+
3220+
def control_characters_c0() -> list[str]:
3221+
"""Returns a list of C0 control characters as strings.
3222+
C0 control characters defined as the byte range 0x00-0x1F, and 0x7F.
3223+
"""
3224+
return [chr(c) for c in range(0x00, 0x20)] + ["\x7F"]

tests/test/support/import_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ def ready_to_import(name=None, source=""):
305305
try:
306306
sys.path.insert(0, tempdir)
307307
yield name, path
308-
sys.path.remove(tempdir)
309308
finally:
309+
sys.path.remove(tempdir)
310310
if old_module is not None:
311311
sys.modules[name] = old_module
312312
else:

0 commit comments

Comments
 (0)