Skip to content

Commit 34e951d

Browse files
committed
Fix define_exception macro not to depend on local context
1 parent e9c098b commit 34e951d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

derive/src/pyclass.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ pub(crate) fn impl_define_exception(
324324
#[pyexception(#class_name, #base_class)]
325325
#[derive(Debug)]
326326
#[doc = #docs]
327-
struct #class_name {}
327+
pub struct #class_name {}
328328

329329
// We need this to make extend mechanism work:
330-
impl PyValue for #class_name {
331-
fn class(vm: &VirtualMachine) -> &PyTypeRef {
330+
impl ::rustpython_vm::PyValue for #class_name {
331+
fn class(vm: &::rustpython_vm::VirtualMachine) -> &::rustpython_vm::builtins::PyTypeRef {
332332
&vm.ctx.exceptions.#ctx_name
333333
}
334334
}
@@ -337,19 +337,19 @@ pub(crate) fn impl_define_exception(
337337
impl #class_name {
338338
#[pyslot]
339339
pub(crate) fn tp_new(
340-
cls: PyTypeRef,
341-
args: FuncArgs,
342-
vm: &VirtualMachine,
343-
) -> PyResult {
340+
cls: ::rustpython_vm::builtins::PyTypeRef,
341+
args: ::rustpython_vm::function::FuncArgs,
342+
vm: &::rustpython_vm::VirtualMachine,
343+
) -> ::rustpython_vm::PyResult {
344344
#tp_new_slot
345345
}
346346

347347
#[pymethod(magic)]
348348
pub(crate) fn init(
349-
zelf: PyRef<PyBaseException>,
350-
args: FuncArgs,
351-
vm: &VirtualMachine,
352-
) -> PyResult<()> {
349+
zelf: ::rustpython_vm::PyRef<::rustpython_vm::exceptions::PyBaseException>,
350+
args: ::rustpython_vm::function::FuncArgs,
351+
vm: &::rustpython_vm::VirtualMachine,
352+
) -> ::rustpython_vm::PyResult<()> {
353353
#init_method
354354
}
355355
}

derive/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ fn func_sig(sig: &Signature) -> String {
530530
if ty == "FuncArgs" {
531531
return Some("*args, **kwargs".to_owned());
532532
}
533-
if ty == "& VirtualMachine" {
533+
if ty.starts_with('&') && ty.ends_with("VirtualMachine") {
534534
return None;
535535
}
536536
let ident = match arg.pat.as_ref() {

0 commit comments

Comments
 (0)