Skip to content

Commit 439b44e

Browse files
committed
Add default parameters to to_bytes based on v3.11 standard
1 parent 887ffd1 commit 439b44e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vm/src/builtins/int.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl PyInt {
614614
#[pymethod]
615615
fn to_bytes(&self, args: IntToByteArgs, vm: &VirtualMachine) -> PyResult<PyBytes> {
616616
let signed = args.signed.map_or(false, Into::into);
617-
let byte_len = args.length.try_to_primitive(vm)?;
617+
let byte_len = args.length;
618618

619619
let value = self.as_bigint();
620620
match value.sign() {
@@ -802,7 +802,9 @@ struct IntFromByteArgs {
802802

803803
#[derive(FromArgs)]
804804
struct IntToByteArgs {
805-
length: PyIntRef,
805+
#[pyarg(any, default = "1")]
806+
length: usize,
807+
#[pyarg(any, default = "ArgByteOrder::Big")]
806808
byteorder: ArgByteOrder,
807809
#[pyarg(named, optional)]
808810
signed: OptionalArg<ArgIntoBool>,

0 commit comments

Comments
 (0)