Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project
adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

### :rocket: Added

- Update code with CPython 3.14.3 version

## [1.3.0] - 2025-12-29

[1.3.0]: https://github.com/rogdham/backports.zstd/releases/tag/v1.3.0
Expand Down
42 changes: 40 additions & 2 deletions tests/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"record_original_stdout", "get_original_stdout", "captured_stdout",
"captured_stdin", "captured_stderr", "captured_output",
# unittest
"is_resource_enabled", "requires", "requires_freebsd_version",
"is_resource_enabled", "get_resource_value", "requires", "requires_resource",
"requires_freebsd_version",
"requires_gil_enabled", "requires_linux_version", "requires_mac_ver",
"check_syntax_error",
"requires_gzip", "requires_bz2", "requires_lzma", "requires_zstd",
Expand All @@ -43,6 +44,7 @@
"check__all__", "skip_if_buggy_ucrt_strfptime",
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
"requires_limited_api", "requires_specialization", "thread_unsafe",
"skip_if_unlimited_stack_size",
# sys
"MS_WINDOWS", "is_jython", "is_android", "is_emscripten", "is_wasi",
"is_apple_mobile", "check_impl_detail", "unix_shell", "setswitchinterval",
Expand Down Expand Up @@ -184,7 +186,7 @@ def get_attribute(obj, name):
return attribute

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

def get_resource_value(resource):
"""Test whether a resource is enabled.

Known resources are set by regrtest.py. If not running under regrtest.py,
all resources are assumed enabled unless use_resources has been set.
"""
if use_resources is None:
return None
return use_resources.get(resource)

def requires(resource, msg=None):
"""Raise ResourceDenied if the specified resource is not available."""
if not is_resource_enabled(resource):
Expand Down Expand Up @@ -1669,6 +1681,25 @@ def skip_if_pgo_task(test):
return test if ok else unittest.skip(msg)(test)


def skip_if_unlimited_stack_size(test):
"""Skip decorator for tests not run when an unlimited stack size is configured.

Tests using support.infinite_recursion([...]) may otherwise run into
an infinite loop, running until the memory on the system is filled and
crashing due to OOM.

See https://github.com/python/cpython/issues/143460.
"""
if is_emscripten or is_wasi or os.name == "nt":
return test

import resource
curlim, maxlim = resource.getrlimit(resource.RLIMIT_STACK)
unlimited_stack_size_cond = curlim == maxlim and curlim in (-1, 0xFFFF_FFFF_FFFF_FFFF)
reason = "Not run due to unlimited stack size"
return unittest.skipIf(unlimited_stack_size_cond, reason)(test)


def detect_api_mismatch(ref_api, other_api, *, ignore=()):
"""Returns the set of items in ref_api not in other_api, except for a
defined list of items to be ignored in this check.
Expand Down Expand Up @@ -3184,3 +3215,10 @@ def linked_to_musl():
return _linked_to_musl
_linked_to_musl = tuple(map(int, version.split('.')))
return _linked_to_musl


def control_characters_c0() -> list[str]:
"""Returns a list of C0 control characters as strings.
C0 control characters defined as the byte range 0x00-0x1F, and 0x7F.
"""
return [chr(c) for c in range(0x00, 0x20)] + ["\x7F"]
2 changes: 1 addition & 1 deletion tests/test/support/import_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ def ready_to_import(name=None, source=""):
try:
sys.path.insert(0, tempdir)
yield name, path
sys.path.remove(tempdir)
finally:
sys.path.remove(tempdir)
if old_module is not None:
sys.modules[name] = old_module
else:
Expand Down