Skip to content

Commit 72fd354

Browse files
authored
Merge pull request RustPython#1727 from youknowone/int-frombytes
Fix int.from_bytes type
2 parents c335791 + fc0c8fd commit 72fd354

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Lib/test/test_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ def test_method_wrapper_types(self):
601601
self.assertIsInstance(object().__lt__, types.MethodWrapperType)
602602
self.assertIsInstance((42).__lt__, types.MethodWrapperType)
603603

604-
# TODO: RUSTPYTHON
605-
@unittest.expectedFailure
606604
def test_method_descriptor_types(self):
607605
self.assertIsInstance(str.join, types.MethodDescriptorType)
608606
self.assertIsInstance(list.append, types.MethodDescriptorType)

vm/src/obj/objint.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,13 @@ impl PyInt {
531531
zelf
532532
}
533533

534-
#[pymethod]
534+
#[pyclassmethod]
535535
#[allow(clippy::match_bool)]
536-
fn from_bytes(args: IntFromByteArgs, vm: &VirtualMachine) -> PyResult<BigInt> {
536+
fn from_bytes(
537+
cls: PyClassRef,
538+
args: IntFromByteArgs,
539+
vm: &VirtualMachine,
540+
) -> PyResult<PyRef<Self>> {
537541
let signed = if let OptionalArg::Present(signed) = args.signed {
538542
signed.to_bool()
539543
} else {
@@ -555,7 +559,7 @@ impl PyInt {
555559
)
556560
}
557561
};
558-
Ok(x)
562+
PyInt::new(x).into_ref_with_type(vm, cls)
559563
}
560564

561565
#[pymethod]

0 commit comments

Comments
 (0)