From e7105643ecf41de308abc33bae78c0fe51c9d7ef Mon Sep 17 00:00:00 2001 From: boris Date: Tue, 2 Feb 2021 09:52:45 -0500 Subject: [PATCH] Fix _random.Random signature --- vm/src/stdlib/random.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vm/src/stdlib/random.rs b/vm/src/stdlib/random.rs index ff604381d..562d66ea5 100644 --- a/vm/src/stdlib/random.rs +++ b/vm/src/stdlib/random.rs @@ -8,7 +8,7 @@ mod _random { use crate::builtins::pytype::PyTypeRef; use crate::common::lock::PyMutex; use crate::function::OptionalOption; - use crate::pyobject::{BorrowValue, PyRef, PyResult, PyValue, StaticType}; + use crate::pyobject::{BorrowValue, PyObjectRef, PyRef, PyResult, PyValue, StaticType}; use crate::VirtualMachine; use num_bigint::{BigInt, Sign}; use num_traits::Signed; @@ -69,7 +69,12 @@ mod _random { #[pyimpl(flags(BASETYPE))] impl PyRandom { #[pyslot(new)] - fn new(cls: PyTypeRef, vm: &VirtualMachine) -> PyResult> { + fn new( + cls: PyTypeRef, + // TODO: use x as the seed. + _x: OptionalOption, + vm: &VirtualMachine, + ) -> PyResult> { PyRandom { rng: PyMutex::default(), } @@ -82,6 +87,7 @@ mod _random { mt19937::gen_res53(&mut *rng) } + // TODO: n can be a float, str, bytes, or bytearray #[pymethod] fn seed(&self, n: OptionalOption) { let new_rng = match n.flatten() {