Yes, that’s what I meant. There are many ways to abuse exec, but your way of using importlib.import_module with tweaked path has the same security issues. One death you have to die and exec seems to be the simplest.
Maybe you explain a bit more why you want to pull out the section from the main file. What is the real purpose?
I want to call the section from two different pieces of code I’m experimenting with right now. At some point some of it will likely end up in a real system, but right now it’s all very exploratory.
Yes, that’s what I meant. There are many ways to abuse exec, but your way of using importlib.import_module with tweaked path has the same security issues. One death you have to die and exec seems to be the simplest.
Maybe you explain a bit more why you want to pull out the section from the main file. What is the real purpose?
I want to call the section from two different pieces of code I’m experimenting with right now. At some point some of it will likely end up in a real system, but right now it’s all very exploratory.
Then security doesn’t matter and you can do whatever is simplest. Even the module space doesn’t matter.