Visitar URL original
Close Python 3.15 rc3 runtime and compiler test failures · RustPython/RustPython@fb0f7b6 · GitHub
Skip to content

Commit fb0f7b6

Browse files
committed
Close Python 3.15 rc3 runtime and compiler test failures
Implement the remaining compiler/JIT, AST and warning, comprehension, string, typing, import, profiling, ctypes/C-API, SSL, SQLite and XML contracts exercised by the refreshed canonical test families. Carry licensed, reproducible parser and XML backports without broad dependency upgrades. Keep genuine optional C-API fixtures feature-gated. Refresh complete rc3 test sources and remove only proven stale native markers; apply the explicitly approved native diagnostic/opcode snapshots. Keep canonical assertions intact and trim duplicate snippet assertions. Validation: workspace 1351 passed/18 ignored; C-API 120 passed/4 ignored; both Clippy gates pass without warnings. All 183 changed Python families have bounded current attempts: 154 execute successfully, 12 wholly skip, 13 hit verified platform restrictions, 3 deny optional resources and 1 has explicit partial coverage. Full snippets: 522 passed/12 platform failures. Existing expected failures and unverified capabilities remain recorded; this does not claim complete Python 3.15 compatibility. Assisted-by: Codex:model-version-unavailable
1 parent 415b3b1 commit fb0f7b6

427 files changed

Lines changed: 49046 additions & 2729 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.

‎.cspell.dict/cpython.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,4 @@ xibufferview
310310
xstat
311311
XXPRIME
312312
ENOTCAPABLE
313+
unmarshalled

‎.cspell.dict/python-more.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,4 @@ xmlcharrefreplace
305305
xoptions
306306
xopts
307307
yieldfrom
308+
issubnormal

‎.cspell.dict/rustpython.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ rustix
3939
struc
4040
unscanned
4141
zelf
42+
embedders

‎.pre-commit-config.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ repos:
3838
entry: rustfmt
3939
language: system
4040
types: [rust]
41+
# Keep the audited upstream source bytes and explicit backports intact.
42+
exclude: '^vendor/(rustpython-ruff_python_parser|xml)/'
4143
priority: 0
4244

4345
- id: generate-rs-opcode-metadata
@@ -67,6 +69,7 @@ repos:
6769
hooks:
6870
- id: cspell
6971
types: [rust]
72+
exclude: '^vendor/(rustpython-ruff_python_parser|xml)/'
7073
additional_dependencies:
7174
- '@cspell/dict-en_us'
7275
- '@cspell/dict-cpp'

‎Cargo.lock‎

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ strip = true
129129
panic = "abort"
130130

131131
[patch.crates-io]
132+
xml = { path = "vendor/xml" }
132133
parking_lot_core = { git = "https://github.com/youknowone/parking_lot", branch = "rustpython" }
134+
rustpython-ruff_python_parser = { path = "vendor/rustpython-ruff_python_parser" }
133135
# REDOX START, Uncomment when you want to compile/check with redoxer
134136
# REDOX END
135137

@@ -158,7 +160,7 @@ members = [
158160
".",
159161
"crates/*",
160162
]
161-
exclude = ["pymath"]
163+
exclude = ["pymath", "vendor/rustpython-ruff_python_parser", "vendor/xml"]
162164

163165
[workspace.package]
164166
version = "0.6.1"

‎Lib/dis.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def get_argval_argrepr(self, op, arg, offset):
643643
argrepr = _intrinsic_2_descs[arg]
644644
elif deop == LOAD_COMMON_CONSTANT:
645645
obj = _common_constants[arg]
646+
argval = obj
646647
if isinstance(obj, type):
647648
argrepr = obj.__name__
648649
else:
@@ -692,10 +693,15 @@ def _get_const_value(op, arg, co_consts):
692693
Otherwise (if it is a LOAD_CONST and co_consts is not
693694
provided) returns the dis.UNKNOWN sentinel.
694695
"""
695-
assert op in hasconst or op == LOAD_SMALL_INT
696+
assert op in hasconst or op == LOAD_SMALL_INT or op == LOAD_COMMON_CONSTANT
696697

697698
if op == LOAD_SMALL_INT:
698699
return arg
700+
if op == LOAD_COMMON_CONSTANT:
701+
# Opargs 0-6 are callables; 7-11 are literal values.
702+
if 7 <= arg <= 11:
703+
return _common_constants[arg]
704+
return UNKNOWN
699705
argval = UNKNOWN
700706
if co_consts is not None:
701707
argval = co_consts[arg]
@@ -1015,8 +1021,9 @@ def _find_imports(co):
10151021
if op == IMPORT_NAME and i >= 2:
10161022
from_op = opargs[i-1]
10171023
level_op = opargs[i-2]
1018-
if (from_op[0] in hasconst and
1019-
(level_op[0] in hasconst or level_op[0] == LOAD_SMALL_INT)):
1024+
if ((from_op[0] in hasconst or from_op[0] == LOAD_COMMON_CONSTANT) and
1025+
(level_op[0] in hasconst or level_op[0] == LOAD_SMALL_INT or
1026+
level_op[0] == LOAD_COMMON_CONSTANT)):
10201027
level = _get_const_value(level_op[0], level_op[1], consts)
10211028
fromlist = _get_const_value(from_op[0], from_op[1], consts)
10221029
yield (names[oparg >> 2], level, fromlist)

‎Lib/opcode.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
4141
_special_method_names = _opcode.get_special_method_names()
4242
_common_constants = [builtins.AssertionError, builtins.NotImplementedError,
43-
builtins.tuple, builtins.all, builtins.any]
43+
builtins.tuple, builtins.all, builtins.any, builtins.list,
44+
builtins.set,
45+
# Append-only — must match CONSTANT_* in
46+
# Include/internal/pycore_opcode_utils.h.
47+
None, "", True, False, -1]
4448
_nb_ops = _opcode.get_nb_ops()
4549

4650
hascompare = [opmap["COMPARE_OP"]]

‎Lib/sysconfig/__init__.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ def _safe_realpath(path):
220220
_PROJECT_BASE = _safe_realpath(os.environ["_PYTHON_PROJECT_BASE"])
221221

222222
def is_python_build():
223+
# RustPython reports source builds without CPython's Modules/Setup files.
224+
if getattr(sys, '_is_python_build', False):
225+
return True
223226
for fn in ("Setup", "Setup.local"):
224227
if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
225228
return True

‎Lib/test/test_annotationlib.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ def f(x: 'int') -> 'str': ...
654654
result = get_annotations(f, eval_str=True)
655655
self.assertEqual(result, {'x': int, 'return': str})
656656

657+
def test_eval_str_wrapped_partial_cycle_self(self):
658+
def f(x: 'int') -> 'str': ...
659+
f.__wrapped__ = functools.partial(f, 0)
660+
# Cycle is detected and broken; globals from f itself are used.
661+
result = get_annotations(f, eval_str=True)
662+
self.assertEqual(result, {'x': int, 'return': str})
663+
657664
def test_eval_str_wrapped_cycle_mutual(self):
658665
# gh-146556: mutual __wrapped__ cycle (a -> b -> a) must not hang.
659666
def a(x: 'int'): ...
@@ -1874,6 +1881,10 @@ def nested():
18741881
type_repr(Template("hi", Interpolation(42, " "))),
18751882
"Template('hi', Interpolation(42, ' ', None, ''))",
18761883
)
1884+
self.assertEqual(
1885+
type_repr(Template("hi", Interpolation(42, "4!2"))),
1886+
"Template('hi', Interpolation(42, '4!2', None, ''))",
1887+
)
18771888
# gh138558: perhaps in the future, we can improve this behavior:
18781889
self.assertEqual(type_repr(Template(Interpolation(42, "99"))), "t'{99}'")
18791890

@@ -2133,8 +2144,13 @@ def f(a: unknown | str | int | list[str] | tuple[int, ...]): ...
21332144
self.assertIsNone(fr.__resolved_str_cache__)
21342145

21352146
self.assertEqual(fr.evaluate(format=Format.STRING), "unknown | str | int | list[str] | tuple[int, ...]")
2147+
2148+
# Test that the cache is now set correctly
21362149
self.assertEqual(fr.__resolved_str_cache__, "unknown | str | int | list[str] | tuple[int, ...]")
21372150

2151+
# Test that future evaluations return the same cache
2152+
self.assertIs(fr.evaluate(format=Format.STRING), fr.__resolved_str_cache__)
2153+
21382154
def test_evaluate_forwardref_format(self):
21392155
fr = ForwardRef("undef")
21402156
evaluated = fr.evaluate(format=Format.FORWARDREF)

0 commit comments

Comments
 (0)