forked from Rust-related/RustPython
_therad.LockType.__new__
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user