Skip to content

Commit ccb66b1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into parallel-ci
2 parents ea0d06e + 3148024 commit ccb66b1

File tree

17 files changed

+258
-32
lines changed

17 files changed

+258
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ jobs:
4848
- uses: dtolnay/rust-toolchain@stable
4949
with:
5050
components: clippy
51-
- uses: Swatinem/rust-cache@v2
51+
52+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
53+
with:
54+
save-if: ${{ github.ref == 'refs/heads/main' }}
5255

5356
- name: Install macOS dependencies
5457
uses: ./.github/actions/install-macos-deps
@@ -131,9 +134,10 @@ jobs:
131134
with:
132135
persist-credentials: false
133136

134-
- uses: Swatinem/rust-cache@v2
137+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
135138
with:
136139
prefix-key: v0-rust-${{ join(matrix.targets, '-') }}
140+
save-if: ${{ github.ref == 'refs/heads/main' }}
137141

138142
- name: Install dependencies
139143
uses: ./.github/actions/install-linux-deps
@@ -216,7 +220,9 @@ jobs:
216220

217221
- uses: dtolnay/rust-toolchain@stable
218222

219-
- uses: Swatinem/rust-cache@v2
223+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
224+
with:
225+
save-if: ${{ github.ref == 'refs/heads/main' }}
220226

221227
- uses: actions/setup-python@v6.2.0
222228
with:
@@ -378,7 +384,9 @@ jobs:
378384
toolchain: ${{ env.NIGHTLY_CHANNEL }}
379385
components: miri
380386

381-
- uses: Swatinem/rust-cache@v2
387+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
388+
with:
389+
save-if: ${{ github.ref == 'refs/heads/main' }}
382390

383391
- name: Run tests under miri
384392
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test -p rustpython-vm -- miri_test
@@ -399,7 +407,10 @@ jobs:
399407

400408
- uses: dtolnay/rust-toolchain@stable
401409

402-
- uses: Swatinem/rust-cache@v2
410+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
411+
with:
412+
save-if: ${{ github.ref == 'refs/heads/main' }}
413+
403414
- name: install wasm-pack
404415
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
405416
- name: install geckodriver
@@ -467,7 +478,10 @@ jobs:
467478
with:
468479
target: wasm32-wasip1
469480

470-
- uses: Swatinem/rust-cache@v2
481+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
482+
with:
483+
save-if: ${{ github.ref == 'refs/heads/main' }}
484+
471485
- name: Setup Wasmer
472486
uses: wasmerio/setup-wasmer@v3
473487

Lib/test/test_class.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ def assertNotOrderable(self, a, b):
614614
with self.assertRaises(TypeError):
615615
a >= b
616616

617+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: 1543448294720 != 1543448295392")
617618
def testHashComparisonOfMethods(self):
618619
# Test comparison and hash of methods
619620
class A:

Lib/test/test_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ def test_non_ascii(self):
423423
self.assertEqual(format(1+2j, "\u2007^8"), "\u2007(1+2j)\u2007")
424424
self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007")
425425

426+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: ',' not found in '123456789'")
426427
def test_locale(self):
427428
try:
428429
oldloc = locale.setlocale(locale.LC_ALL)

Lib/test/test_math.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,7 @@ def testRadians(self):
17381738
self.ftest('radians(-45)', math.radians(-45), -math.pi/4)
17391739
self.ftest('radians(0)', math.radians(0), 0)
17401740

1741+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; Error message too long")
17411742
@requires_IEEE_754
17421743
def testRemainder(self):
17431744
from fractions import Fraction

Lib/test/test_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ def test(i, format_spec, result):
431431
test(123456, "1=20", '11111111111111123456')
432432
test(123456, "*=20", '**************123456')
433433

434+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: '1,234.57' != '1234.57'")
434435
@run_with_locale('LC_NUMERIC', 'en_US.UTF8', '')
435436
def test_float__format__locale(self):
436437
# test locale support for __format__ code 'n'
@@ -440,6 +441,7 @@ def test_float__format__locale(self):
440441
self.assertEqual(locale.format_string('%g', x, grouping=True), format(x, 'n'))
441442
self.assertEqual(locale.format_string('%.10g', x, grouping=True), format(x, '.10n'))
442443

444+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: '123,456,789,012,345,678,901,234,567,890' != '123456789012345678901234567890'")
443445
@run_with_locale('LC_NUMERIC', 'en_US.UTF8', '')
444446
def test_int__format__locale(self):
445447
# test locale support for __format__ code 'n' for integers

crates/vm/src/builtins/bool.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,26 @@ impl Representable for PyBool {
182182
}
183183
}
184184

185+
fn vectorcall_bool(
186+
zelf_obj: &PyObject,
187+
args: Vec<PyObjectRef>,
188+
nargs: usize,
189+
kwnames: Option<&[PyObjectRef]>,
190+
vm: &VirtualMachine,
191+
) -> PyResult {
192+
let zelf: &Py<PyType> = zelf_obj.downcast_ref().unwrap();
193+
let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
194+
(zelf.slots.new.load().unwrap())(zelf.to_owned(), func_args, vm)
195+
}
196+
185197
pub(crate) fn init(context: &'static Context) {
186198
PyBool::extend_class(context, context.types.bool_type);
199+
context
200+
.types
201+
.bool_type
202+
.slots
203+
.vectorcall
204+
.store(Some(vectorcall_bool));
187205
}
188206

189207
// pub fn not(vm: &VirtualMachine, obj: &PyObject) -> PyResult<bool> {

crates/vm/src/builtins/dict.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use crate::{
1515
class::{PyClassDef, PyClassImpl},
1616
common::ascii,
1717
dict_inner::{self, DictKey},
18-
function::{ArgIterable, KwArgs, OptionalArg, PyArithmeticValue::*, PyComparisonValue},
18+
function::{
19+
ArgIterable, FuncArgs, KwArgs, OptionalArg, PyArithmeticValue::*, PyComparisonValue,
20+
},
1921
iter::PyExactSizeIterator,
2022
protocol::{PyIterIter, PyIterReturn, PyMappingMethods, PyNumberMethods, PySequenceMethods},
2123
recursion::ReprGuard,
@@ -1433,8 +1435,28 @@ fn set_inner_number_or(a: &PyObject, b: &PyObject, vm: &VirtualMachine) -> PyRes
14331435
set_inner_number_op(a, b, |a, b| a.union(b, vm), vm)
14341436
}
14351437

1438+
fn vectorcall_dict(
1439+
zelf_obj: &PyObject,
1440+
args: Vec<PyObjectRef>,
1441+
nargs: usize,
1442+
kwnames: Option<&[PyObjectRef]>,
1443+
vm: &VirtualMachine,
1444+
) -> PyResult {
1445+
let zelf: &Py<PyType> = zelf_obj.downcast_ref().unwrap();
1446+
let obj = PyDict::default().into_ref_with_type(vm, zelf.to_owned())?;
1447+
let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
1448+
PyDict::slot_init(obj.clone().into(), func_args, vm)?;
1449+
Ok(obj.into())
1450+
}
1451+
14361452
pub(crate) fn init(context: &'static Context) {
14371453
PyDict::extend_class(context, context.types.dict_type);
1454+
context
1455+
.types
1456+
.dict_type
1457+
.slots
1458+
.vectorcall
1459+
.store(Some(vectorcall_dict));
14381460
PyDictKeys::extend_class(context, context.types.dict_keys_type);
14391461
PyDictKeyIterator::extend_class(context, context.types.dict_keyiterator_type);
14401462
PyDictReverseKeyIterator::extend_class(context, context.types.dict_reversekeyiterator_type);

crates/vm/src/builtins/float.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,20 @@ pub(crate) fn get_value(obj: &PyObject) -> f64 {
525525
obj.downcast_ref::<PyFloat>().unwrap().value
526526
}
527527

528+
fn vectorcall_float(
529+
zelf_obj: &PyObject,
530+
args: Vec<PyObjectRef>,
531+
nargs: usize,
532+
kwnames: Option<&[PyObjectRef]>,
533+
vm: &VirtualMachine,
534+
) -> PyResult {
535+
let zelf: &Py<PyType> = zelf_obj.downcast_ref().unwrap();
536+
let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
537+
(zelf.slots.new.load().unwrap())(zelf.to_owned(), func_args, vm)
538+
}
539+
528540
#[rustfmt::skip] // to avoid line splitting
529541
pub fn init(context: &'static Context) {
530542
PyFloat::extend_class(context, context.types.float_type);
543+
context.types.float_type.slots.vectorcall.store(Some(vectorcall_float));
531544
}

crates/vm/src/builtins/int.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,24 @@ pub fn try_to_float(int: &BigInt, vm: &VirtualMachine) -> PyResult<f64> {
791791
.ok_or_else(|| vm.new_overflow_error("int too large to convert to float"))
792792
}
793793

794+
fn vectorcall_int(
795+
zelf_obj: &PyObject,
796+
args: Vec<PyObjectRef>,
797+
nargs: usize,
798+
kwnames: Option<&[PyObjectRef]>,
799+
vm: &VirtualMachine,
800+
) -> PyResult {
801+
let zelf: &Py<PyType> = zelf_obj.downcast_ref().unwrap();
802+
let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
803+
(zelf.slots.new.load().unwrap())(zelf.to_owned(), func_args, vm)
804+
}
805+
794806
pub(crate) fn init(context: &'static Context) {
795807
PyInt::extend_class(context, context.types.int_type);
808+
context
809+
.types
810+
.int_type
811+
.slots
812+
.vectorcall
813+
.store(Some(vectorcall_int));
796814
}

crates/vm/src/builtins/list.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,24 @@ impl IterNext for PyListReverseIterator {
768768
}
769769
}
770770

771+
fn vectorcall_list(
772+
zelf_obj: &PyObject,
773+
args: Vec<PyObjectRef>,
774+
nargs: usize,
775+
kwnames: Option<&[PyObjectRef]>,
776+
vm: &VirtualMachine,
777+
) -> PyResult {
778+
let zelf: &Py<PyType> = zelf_obj.downcast_ref().unwrap();
779+
let obj = PyList::default().into_ref_with_type(vm, zelf.to_owned())?;
780+
let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
781+
PyList::slot_init(obj.clone().into(), func_args, vm)?;
782+
Ok(obj.into())
783+
}
784+
771785
pub fn init(context: &'static Context) {
772786
let list_type = &context.types.list_type;
773787
PyList::extend_class(context, list_type);
788+
list_type.slots.vectorcall.store(Some(vectorcall_list));
774789

775790
PyListIterator::extend_class(context, context.types.list_iterator_type);
776791
PyListReverseIterator::extend_class(context, context.types.list_reverseiterator_type);

0 commit comments

Comments
 (0)