Skip to content

Commit 2b03849

Browse files
Fix test_bool test_subclass
1 parent f21ad9b commit 2b03849

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,
@@ -210,6 +210,9 @@ impl Constructor for PyInt {
210210
type Args = IntOptions;
211211

212212
fn py_new(cls: PyTypeRef, options: Self::Args, vm: &VirtualMachine) -> PyResult {
213+
if cls.is(PyBool::class(vm)) {
214+
return Err(vm.new_type_error("int.__new__(bool) is not safe, use bool.__new__()".to_owned()));
215+
}
213216
let value = if let OptionalArg::Present(val) = options.val_options {
214217
if let OptionalArg::Present(base) = options.base {
215218
let base = base

0 commit comments

Comments
 (0)