Skip to content

Commit 9ede5fd

Browse files
minhrongcon2000youknowone
authored andcommitted
Fix test_bool test_subclass
1 parent 70fb78d commit 9ede5fd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/test/test_bool.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import os
77

88
class BoolTest(unittest.TestCase):
9-
10-
# TODO: RUSTPYTHON
11-
@unittest.expectedFailure
129
def test_subclass(self):
1310
try:
1411
class C(bool):

vm/src/builtins/int.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{float, PyByteArray, PyBytes, PyStr, PyType, PyTypeRef};
1+
use super::{float, PyByteArray, PyBytes, PyStr, PyType, PyTypeRef, PyBool};
22
use crate::{
33
builtins::PyStrRef,
44
bytesinner::PyBytesInner,
@@ -213,6 +213,9 @@ impl Constructor for PyInt {
213213
type Args = IntOptions;
214214

215215
fn py_new(cls: PyTypeRef, options: Self::Args, vm: &VirtualMachine) -> PyResult {
216+
if cls.is(PyBool::class(vm)) {
217+
return Err(vm.new_type_error("int.__new__(bool) is not safe, use bool.__new__()".to_owned()));
218+
}
216219
let value = if let OptionalArg::Present(val) = options.val_options {
217220
if let OptionalArg::Present(base) = options.base {
218221
let base = base

0 commit comments

Comments
 (0)