_therad.LockType.__new__

This commit is contained in:
Jeong YunWon
2021-10-05 19:34:06 +09:00
parent 5254265e3a
commit 2ca3dc4468

View File

@@ -5,7 +5,7 @@ use crate::{
exceptions::{self, IntoPyException},
function::{ArgCallable, FuncArgs, KwArgs, OptionalArg},
py_io,
slots::{SlotGetattro, SlotSetattro},
slots::{SlotConstructor, SlotGetattro, SlotSetattro},
utils::Either,
IdProtocol, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
VirtualMachine,
@@ -103,7 +103,7 @@ impl fmt::Debug for PyLock {
}
}
#[pyimpl]
#[pyimpl(with(SlotConstructor))]
impl PyLock {
#[pymethod]
#[pymethod(name = "acquire_lock")]
@@ -138,6 +138,13 @@ impl PyLock {
}
}
impl SlotConstructor for PyLock {
type Args = FuncArgs;
fn py_new(_cls: PyTypeRef, _args: Self::Args, vm: &VirtualMachine) -> PyResult {
Err(vm.new_type_error("cannot create '_thread.lock' instances".to_owned()))
}
}
pub type RawRMutex = RawReentrantMutex<RawMutex, RawThreadId>;
#[pyclass(module = "thread", name = "RLock")]
#[derive(PyValue)]