mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
* Target Python 3.15 using the final upstream reference Update active version and comparison configuration to Python 3.15.0. Preserve the alpha implementation status, actual bytecode format, and existing libraries pending separate migration. Align generated library-upgrade workflow pins without changing permissions or actions. Assisted-by: OpenAI Codex:model identifier unavailable * Adapt essential snippet contracts to Python 3.15 final Preserve existing coverage while following verified final behavior for script metadata, builtin signatures and loading, AST fixture construction, memoryview diagnostics, mmap search bounds, and struct format errors. The unchanged final comparator exposes the earlier expectations; focused native baseline failures establish the required implementation changes. Assisted-by: OpenAI Codex:model identifier unavailable * Keep final-reference regression paths and remove expired sysconfig argument Preserve reverse multiplication syntax and native exact overflow diagnostics. Accept the two source-proven CPython 3.15 specialization messages only in affected reverse str/bytes/tuple cases. Use an actually out-of-range Windows datetime errno fixture. Remove the sysconfig check_home argument at its existing canonical 3.15 removal test boundary. Assisted-by: OpenAI Codex:model identifier unavailable * Keep README wording unchanged in Python 3.15 transition Assisted-by: OpenAI Codex:model identifier unavailable * Match Python 3.15 repetition specialization and keep universal tests Use exact sequence-type guards and preserve generic fallback diagnostics. Validate both cold and warmed expressions without implementation-specific assertions. Reject stale CPython source checkouts and cross-version library caches. Assisted-by: OpenAI Codex:model identifier unavailable * Limit in-place specialization additions to exact sequence repetition Assisted-by: OpenAI Codex:model identifier unavailable * Keep subclass regression scoped to repetition dispatch Assisted-by: OpenAI Codex:model identifier unavailable * Provision final CPython 3.15 with pinned uv builds Assisted-by: OpenAI Codex:model identifier unavailable * Enforce Python 3.15 AST constructor requirements Reject retired missing-field and arbitrary-keyword forms while preserving defaults and explicit placeholders. Sync only matching final CPython constructor test hunks. Assisted-by: OpenAI Codex:model identifier unavailable * Keep seeded Python ahead of its Windows DLL directory Assisted-by: OpenAI Codex:model identifier unavailable * Keep opcode metadata tied to the implemented bytecode format The interpreter target and reference tests use Python 3.15.0, but the current Rust opcode enum retains the 3.14 bytecode format. Generate metadata from its matching source rather than importing unsupported instruction families. Assisted-by: OpenAI Codex:model identifier unavailable * Align CSV, logarithm and decimal formatting with Python 3.15 Propagate dialect lookup errors except AttributeError, retry integer logarithms after float overflow, and update the decimal conversion diagnostic. Exercise the final reference contracts without implementation-specific branches. Assisted-by: OpenAI Codex:model identifier unavailable * Bind the logarithm index result before borrowing its integer Assisted-by: OpenAI Codex:model identifier unavailable * Align required canonical test expectations with Python 3.15 Take only demonstrated contract changes from CPython v3.15.0, d220409a13b77de7a6c30abe16ea90db01528edc: removed module __cached__, Struct format exception classes, and decimal-format diagnostic. Preserve unrelated tests and expectations. Assisted-by: OpenAI Codex:model identifier unavailable * Track pending frozendict pickle support during the 3.15 transition Keep the two existing frozendict pickle tests running as expected failures until #8951 supplies the builtin. Unexpected success will signal removal of these temporary markers. Assisted-by: OpenAI Codex:model identifier unavailable * Support final Python 3.15 Windows negative timestamps Use FILETIME for pre-epoch conversions and preserve precise Windows timestamp errors. Assisted-by: OpenAI Codex:model identifier unavailable * Derive historical Windows timezone offsets from wall time FILETIME reports historical DST as unknown, so calculate the actual offset rather than selecting standard-time bias. Assisted-by: OpenAI Codex:model identifier unavailable * Identify decimal formatting arguments in Python 3.15 errors Track consumed positional arguments, including star width and precision, and preserve mapping key representations in decimal conversion diagnostics. Assisted-by: OpenAI Codex:model identifier unavailable * Reuse mapping format keys for lookup and error context Assisted-by: OpenAI Codex:model identifier unavailable * Borrow mapping diagnostic keys as Python objects Assisted-by: OpenAI Codex:model identifier unavailable * Avoid empty components in the reference Python library path Assisted-by: OpenAI Codex:model identifier unavailable * Isolate RustPython bytecode caches during the 3.15 transition Assisted-by: OpenAI Codex:model identifier unavailable * Sync final Windows timestamp test expectations Import only the final CPython platform-limit guards and mktime roundtrip expectation required by the existing Windows CI suite. Assisted-by: OpenAI Codex:model identifier unavailable * Restore official Python setup for 3.15 final Use the existing pinned setup-python action now that its official catalog supplies CPython 3.15.0. Remove the temporary standalone provisioning action and its sparse-checkout entry while retaining interpreter outputs and requested versions. Assisted-by: OpenAI Codex:model identifier unavailable * Align merged runtime contracts with Python 3.15 final Restrict mappingproxy ordering, use final codec registry normalization, and prefer index conversion before float conversion for sleep. Retain universal Python assertions and import the matching final codec/time canonical test hunks plus the non-ASCII codec-name deprecation warning. Upstream source: CPython d220409a13b77de7a6c30abe16ea90db01528edc. The existing codec normalization implementation and bytecode contract remain unchanged. Assisted-by: OpenAI Codex:model identifier unavailable * Limit Windows launcher version check to its interpreter Exclude only the CPython py.exe version-identity case from RustPython CI. The installed launcher reports its own final version, while RustPython correctly remains alpha. Preserve the other 45 launcher cases and all RustPython version assertions without modifying Lib. Assisted-by: OpenAI Codex:model identifier unavailable --------- Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
88 lines
2.5 KiB
Python
88 lines
2.5 KiB
Python
import _imp
|
|
import time as import_time
|
|
|
|
from testutils import assert_raises, skip_if_unsupported
|
|
|
|
assert _imp.is_builtin("time") == True
|
|
assert _imp.is_builtin("os") == False
|
|
assert _imp.is_builtin("not existing module") == False
|
|
|
|
assert _imp.is_frozen("__hello__") == True
|
|
assert _imp.is_frozen("math") == False
|
|
|
|
|
|
class FakeSpec:
|
|
def __init__(self, name):
|
|
self.name = name
|
|
|
|
|
|
A = FakeSpec("time")
|
|
|
|
imp_time = _imp.create_builtin(A)
|
|
# FIXME: cpython3.9 fail
|
|
# assert imp_time.sleep == import_time.sleep
|
|
|
|
B = FakeSpec("not existing module")
|
|
with assert_raises(ModuleNotFoundError):
|
|
_imp.create_builtin(B)
|
|
|
|
_imp.exec_builtin(imp_time) == 0
|
|
|
|
_imp.get_frozen_object("__hello__")
|
|
|
|
hello = _imp.init_frozen("__hello__")
|
|
assert hello.initialized == True
|
|
|
|
# withdata is keyword-only
|
|
with assert_raises(TypeError):
|
|
_imp.find_frozen("x", True)
|
|
assert _imp.find_frozen("_this_module_does_not_exist_") is None
|
|
|
|
# and it hands back the marshalled code that get_frozen_object() takes
|
|
data, ispkg, origname = _imp.find_frozen("__hello__", withdata=True)
|
|
assert ispkg is False
|
|
assert origname == "__hello__"
|
|
assert _imp.get_frozen_object("__hello__", data).co_name == "<module>"
|
|
|
|
|
|
def test_lazy_attributes_eager_registry():
|
|
# CPython accepts any first argument and a string name. In an eager-only
|
|
# interpreter there are no pending lazy module names to remove.
|
|
for modobj in (None, object(), {}, 42):
|
|
assert _imp._set_lazy_attributes(modobj, "package.module") is None
|
|
assert _imp._set_lazy_attributes(modobj, "\ud800") is None
|
|
|
|
for name in (None, 1, b"package.module", [], {}):
|
|
with assert_raises(TypeError):
|
|
_imp._set_lazy_attributes(None, name)
|
|
|
|
with assert_raises(TypeError):
|
|
_imp._set_lazy_attributes(modobj=None, name="package.module")
|
|
|
|
class ModuleName(str):
|
|
hashes = 0
|
|
|
|
def __hash__(self):
|
|
self.hashes += 1
|
|
return 42
|
|
|
|
name = ModuleName("package.module")
|
|
assert _imp._set_lazy_attributes(None, name) is None
|
|
assert name.hashes == 1
|
|
|
|
class UnhashableName(str):
|
|
__hash__ = None
|
|
|
|
with assert_raises(TypeError):
|
|
_imp._set_lazy_attributes(None, UnhashableName("package.module"))
|
|
|
|
class HashErrorName(str):
|
|
def __hash__(self):
|
|
raise RuntimeError("name hash failed")
|
|
|
|
with assert_raises(RuntimeError):
|
|
_imp._set_lazy_attributes(None, HashErrorName("package.module"))
|
|
|
|
|
|
skip_if_unsupported(3, 15, test_lazy_attributes_eager_registry)
|