Skip to content

Commit 39169f0

Browse files
committed
Add RLock.tp_new
1 parent bb69eda commit 39169f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

vm/src/stdlib/thread.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Implementation of the _thread module
22
use crate::function::PyFuncArgs;
33
use crate::obj::objtype::PyClassRef;
4-
use crate::pyobject::{PyClassImpl, PyObjectRef, PyResult, PyValue};
4+
use crate::pyobject::{PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue};
55
use crate::vm::VirtualMachine;
66

77
use parking_lot::{
@@ -189,7 +189,7 @@ impl PyValue for PyRLock {
189189

190190
impl fmt::Debug for PyRLock {
191191
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
192-
f.pad("PyLock")
192+
f.pad("PyRLock")
193193
}
194194
}
195195

@@ -201,7 +201,15 @@ impl LockProtocol for PyRLock {
201201
}
202202

203203
#[pyimpl(with(LockProtocol))]
204-
impl PyRLock {}
204+
impl PyRLock {
205+
#[pyslot]
206+
fn tp_new(cls: PyClassRef, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
207+
PyRLock {
208+
mu: RawRMutex::INIT,
209+
}
210+
.into_ref_with_type(vm, cls)
211+
}
212+
}
205213

206214
fn get_ident() -> u64 {
207215
let id = std::thread::current().id();

0 commit comments

Comments
 (0)