Debugging tainted namespace on profile modules.

This commit is contained in:
Anton Hvornum 2021-03-21 15:00:08 +01:00
parent c99abb1a7b
commit 27bde44b8d
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
1 changed files with 5 additions and 7 deletions

View File

@ -126,17 +126,15 @@ class Script():
raise ProfileNotFound(f"Cannot handle scheme {parsed_url.scheme}")
def load_instructions(self, namespace=None):
if not namespace:
namespace = self.namespace
if namespace:
self.namespace = namespace
self.spec = importlib.util.spec_from_file_location(namespace, self.path)
self.spec = importlib.util.spec_from_file_location(self.namespace, self.path)
imported = importlib.util.module_from_spec(self.spec)
sys.modules[namespace] = imported
sys.modules[self.namespace] = imported
print(f"Imported {self} into sys.modules with namespace {namespace}.")
print(f"Imported {self} into sys.modules with namespace {self.namespace}.")
if '.py' not in namespace:
raise KeyError("Debugging")
return self
def execute(self):