GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — imply parent module · RustPython/RustPython@3569b0a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates/derive-impl/src
    • pymodule.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/derive-impl/src/pymodule.rs‎

Copy file name to clipboardExpand all lines: crates/derive-impl/src/pymodule.rs
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ pub fn impl_pymodule(args: PyModuleArgs, module_item: Item) -> Result<TokenStrea
234234
#(#cfgs)*
235235
{
236236
let child_def = #mod_ident::module_def(ctx);
237-
let child = child_def.create_module(vm).unwrap();
238-
child.__init_methods(vm).unwrap();
239-
#mod_ident::module_exec(vm, &child).unwrap();
237+
let child = child_def.create_module(vm).expect("submodule create_module failed");
238+
child.__init_methods(vm).expect("submodule __init_methods failed");
239+
#mod_ident::module_exec(vm, &child).expect("submodule module_exec failed");
240240
let child: ::rustpython_vm::PyObjectRef = child.into();
241-
vm.__module_set_attr(module, ctx.intern_str(#py_name), child).unwrap();
241+
vm.__module_set_attr(module, ctx.intern_str(#py_name), child).expect("module set_attr submodule failed");
242242
}
243243
});
244244
Ok(())
@@ -837,7 +837,15 @@ impl ModuleItem for StructSequenceItem {
837837
"#[pystruct_sequence] requires name parameter",
838838
)
839839
})?;
840-
let module_name = meta.module()?.unwrap_or_else(|| args.context.name.clone());
840+
let module_opt = meta.module()?;
841+
let has_module = module_opt.is_some();
842+
let module_name = module_opt.unwrap_or_else(|| args.context.name.clone());
843+
if !has_module {
844+
let structseq_attr = &mut args.attrs[self.inner.index];
845+
structseq_attr.fill_nested_meta("module", || {
846+
parse_quote! {module = #module_name}
847+
})?;
848+
}
841849
let no_attr = meta.no_attr()?;
842850

843851
// Generate the class creation code

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.