Skip to content

Commit b31f23f

Browse files
committed
Add RLock.tp_new
1 parent f103b0c commit b31f23f

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::{
@@ -190,7 +190,7 @@ impl PyValue for PyRLock {
190190

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

@@ -202,7 +202,15 @@ impl LockProtocol for PyRLock {
202202
}
203203

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

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

0 commit comments

Comments
 (0)