fix for test test_bool.BoolTest.test_subclass

This commit is contained in:
hydrogen602
2024-04-20 16:11:38 -05:00
committed by Jeong, YunWon
parent 4a939141f6
commit be6ea2a7b8
2 changed files with 6 additions and 2 deletions

View File

@@ -7,8 +7,6 @@ import os
class BoolTest(unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subclass(self):
try:
class C(bool):

View File

@@ -212,6 +212,12 @@ impl Constructor for PyInt {
type Args = IntOptions;
fn py_new(cls: PyTypeRef, options: Self::Args, vm: &VirtualMachine) -> PyResult {
if cls.is(vm.ctx.types.bool_type) {
return Err(
vm.new_type_error("int.__new__(bool) is not safe, use bool.__new__()".to_owned())
);
}
let value = if let OptionalArg::Present(val) = options.val_options {
if let OptionalArg::Present(base) = options.base {
let base = base