Adding exception to the main section fails when using MultiSectionFactory
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PyBindGen |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I am using MultiSectionFactory to split the generated code. However there is one common exception across all sections that I intend to add to the main section.
mod = Module(module_name)
section_list = ["foo", "bar", "baz"]
out = GeomMultiSectio
# Common exception
excp = mod.add_
for section in section_list:
mod.begin_
# do something
mod.end_
mod.generate(out, module_name)
This gives me the following pybindgen error:
Traceback (most recent call last):
File "Main.py", line 83, in <module>
mod.
File "pybindgen/
self.
File "pybindgen/
sink, header_sink = out.get_
File "pybindgen/
section_sink = self.multi_
File "/home/utils.py", line 49, in get_section_
return self.section_
KeyError: '__main__'
Changing the if-check
'if section is None' in the method get_code_
to
'if section == "__main__"' fixes the problem